Skip to content

Commit abc0b7c

Browse files
authored
Merge pull request #649 from trycompai/claudio/comp-127-drop-entityid-and-entitytype-from-tasks
[dev] [claudfuen] claudio/comp-127-drop-entityid-and-entitytype-from-tasks
2 parents fc6aff0 + bfbad29 commit abc0b7c

File tree

29 files changed

+146
-277
lines changed

29 files changed

+146
-277
lines changed

apps/app/src/actions/organization/lib/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
type PolicyStatus,
77
RequirementId,
88
TaskStatus,
9-
TaskEntityType,
109
TaskFrequency,
1110
Departments,
1211
ArtifactType,

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/controls/[controlId]/data/getOrganizationControlProgress.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { auth } from "@/utils/auth";
44
import { db } from "@comp/db";
5-
import { TaskEntityType } from "@comp/db/types";
65
import { ArtifactType } from "@prisma/client";
76
import { headers } from "next/headers";
87

@@ -110,15 +109,8 @@ export const getOrganizationControlProgress = async (controlId: string) => {
110109

111110
progress.byType["control"].total++;
112111

113-
// Check completion based on task type
114-
let isCompleted = false;
115-
switch (task.entityType) {
116-
case TaskEntityType.control:
117-
isCompleted = task.status === "done";
118-
break;
119-
default:
120-
isCompleted = false;
121-
}
112+
// Check completion based on task status (all tasks here are implicitly control-related)
113+
const isCompleted = task.status === "done";
122114

123115
if (isCompleted) {
124116
progress.completed++;

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/controls/[controlId]/data/getRelatedTasks.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/controls/[controlId]/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { SingleControl } from "./components/SingleControl";
66
import { getControl } from "./data/getControl";
77
import { getOrganizationControlProgress } from "./data/getOrganizationControlProgress";
88
import type { ControlProgressResponse } from "./data/getOrganizationControlProgress";
9-
import { getRelatedTasks } from "./data/getRelatedTasks";
109
import { getRelatedArtifacts } from "./data/getRelatedArtifacts";
1110

1211
interface ControlPageProps {

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/frameworks/[frameworkInstanceId]/components/FrameworkOverview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { Progress } from "@comp/ui/progress";
66
import { getFrameworkDetails } from "../../lib/getFrameworkDetails";
77
import { getControlStatus } from "../../lib/utils";
88
import { FrameworkInstanceWithControls } from "../../types";
9-
import { Task } from "@comp/db/types";
9+
import { Control, Task } from "@comp/db/types";
1010

1111
interface FrameworkOverviewProps {
1212
frameworkInstanceWithControls: FrameworkInstanceWithControls;
13-
tasks: Task[];
13+
tasks: (Task & { controls: Control[] })[];
1414
}
1515

1616
export function FrameworkOverview({

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/frameworks/[frameworkInstanceId]/page.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getFrameworkDetails } from "../lib/getFrameworkDetails";
77
import { FrameworkOverview } from "./components/FrameworkOverview";
88
import { FrameworkRequirements } from "./components/FrameworkRequirements";
99
import { db } from "@comp/db";
10-
import { TaskEntityType } from "@comp/db/types";
10+
1111
interface PageProps {
1212
params: Promise<{
1313
frameworkInstanceId: string;
@@ -48,7 +48,14 @@ export default async function FrameworkPage({ params }: PageProps) {
4848
const tasks = await db.task.findMany({
4949
where: {
5050
organizationId,
51-
entityType: TaskEntityType.control,
51+
controls: {
52+
some: {
53+
id: frameworkInstanceWithControls.id,
54+
},
55+
},
56+
},
57+
include: {
58+
controls: true,
5259
},
5360
});
5461

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/frameworks/[frameworkInstanceId]/requirements/[requirementKey]/components/RequirementControls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { FrameworkId } from "@comp/db/types";
66
import { Card, CardContent, CardHeader, CardTitle } from "@comp/ui/card";
77
import { FrameworkInstanceWithControls } from "../../../../types";
88
import { RequirementControlsTable } from "./table/RequirementControlsTable";
9-
import type { Task } from "@comp/db/types";
9+
import type { Control, Task } from "@comp/db/types";
1010

1111
interface RequirementControlsProps {
1212
requirement: Requirement;
1313
requirementKey: string;
1414
frameworkInstanceWithControls: FrameworkInstanceWithControls;
15-
tasks: Task[];
15+
tasks: (Task & { controls: Control[] })[];
1616
}
1717

1818
export function RequirementControls({

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/frameworks/[frameworkInstanceId]/requirements/[requirementKey]/components/table/RequirementControlsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface RequirementControlsTableProps {
2727
policy: Policy | null;
2828
})[];
2929
})[];
30-
tasks: Task[];
30+
tasks: (Task & { controls: Control[] })[];
3131
}
3232

3333
export function RequirementControlsTable({

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/frameworks/[frameworkInstanceId]/requirements/[requirementKey]/components/table/RequirementControlsTableColumns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type OrganizationControlType = Control & {
2626
export function RequirementControlsTableColumns({
2727
tasks,
2828
}: {
29-
tasks: Task[];
29+
tasks: (Task & { controls: Control[] })[];
3030
}): ColumnDef<OrganizationControlType>[] {
3131
const t = useI18n();
3232
const { orgId } = useParams<{ orgId: string }>();

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/frameworks/[frameworkInstanceId]/requirements/[requirementKey]/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { getFrameworkDetails } from "../../../lib/getFrameworkDetails";
77
import { getFrameworkRequirements } from "../../../lib/getFrameworkRequirements";
88
import { RequirementControls } from "./components/RequirementControls";
99
import { db } from "@comp/db";
10-
import { TaskEntityType } from "@comp/db/types";
1110

1211
interface PageProps {
1312
params: Promise<{
@@ -70,7 +69,14 @@ export default async function RequirementPage({ params }: PageProps) {
7069
(await db.task.findMany({
7170
where: {
7271
organizationId,
73-
entityType: TaskEntityType.control,
72+
controls: {
73+
some: {
74+
id: frameworkInstanceWithControls.id,
75+
},
76+
},
77+
},
78+
include: {
79+
controls: true,
7480
},
7581
})) || [];
7682

0 commit comments

Comments
 (0)