Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions apps/app/src/app/(app)/[orgId]/frameworks/lib/getPeople.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { trainingVideos } from '@/lib/data/training-videos';
import { getFleetInstance } from '@/lib/fleet';
import { db } from '@db';

export async function getPeopleScore(organizationId: string) {
Expand Down Expand Up @@ -50,7 +49,7 @@ export async function getPeopleScore(organizationId: string) {
const requiredTrainingVideoIds = trainingVideos.map((video) => video.id);

// Get fleet instance for device checks
const fleet = await getFleetInstance();
// const fleet = await getFleetInstance();

// Check each employee's completion status
let completedMembers = 0;
Expand All @@ -73,9 +72,9 @@ export async function getPeopleScore(organizationId: string) {
);

// 3. Check if device is secure
let hasSecureDevice = true;
// let hasSecureDevice = false;

if (employee.fleetDmLabelId) {
/* if (employee.fleetDmLabelId) {
try {
const deviceResponse = await fleet.get(`/labels/${employee.fleetDmLabelId}/hosts`);
const device = deviceResponse.data.hosts?.[0];
Expand All @@ -91,10 +90,9 @@ export async function getPeopleScore(organizationId: string) {
// If there's an error fetching device, consider it not secure
hasSecureDevice = false;
}
}
} */

// Employee is "done" if all three conditions are met
if (hasAcceptedAllPolicies && hasCompletedAllTraining && hasSecureDevice) {
if (hasAcceptedAllPolicies && hasCompletedAllTraining) {
completedMembers++;
}
}
Expand Down
49 changes: 43 additions & 6 deletions apps/app/src/app/(app)/[orgId]/frameworks/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,61 @@ export default async function DashboardPage({ params }: { params: Promise<{ orgI
},
});

const publishedPoliciesScore = await getPublishedPoliciesScore(organizationId);
const doneTasksScore = await getDoneTasks(organizationId);
const peopleScore = await getPeopleScore(organizationId);
const scores = await getScores();

return (
<Overview
frameworksWithControls={frameworksWithControls}
frameworksWithCompliance={frameworksWithCompliance}
allFrameworks={allFrameworks}
organizationId={organizationId}
publishedPoliciesScore={publishedPoliciesScore}
doneTasksScore={doneTasksScore}
peopleScore={peopleScore}
publishedPoliciesScore={scores.publishedPoliciesScore}
doneTasksScore={scores.doneTasksScore}
peopleScore={scores.peopleScore}
currentMember={member}
/>
);
}

const getScores = cache(async () => {
const session = await auth.api.getSession({
headers: await headers(),
});

const organizationId = session?.session.activeOrganizationId;

if (!organizationId) {
return {
publishedPoliciesScore: {
totalPolicies: 0,
publishedPolicies: 0,
draftPolicies: [],
policiesInReview: [],
unpublishedPolicies: [],
},
doneTasksScore: {
totalTasks: 0,
doneTasks: 0,
incompleteTasks: [],
},
peopleScore: {
totalMembers: 0,
completedMembers: 0,
},
};
}

const publishedPoliciesScore = await getPublishedPoliciesScore(organizationId);
const doneTasksScore = await getDoneTasks(organizationId);
const peopleScore = await getPeopleScore(organizationId);

return {
publishedPoliciesScore,
doneTasksScore,
peopleScore,
};
});

const getControlTasks = cache(async () => {
const session = await auth.api.getSession({
headers: await headers(),
Expand Down
Loading