cd78f72f33
Complete rename of all technical identifiers across the codebase: Package names (11 packages): - @planarchy/* → @capakraken/* in all package.json, tsconfig, imports Import statements: 277 files, 548 occurrences replaced Database & Docker: - PostgreSQL user/db: planarchy → capakraken - Docker volumes: planarchy_pgdata → capakraken_pgdata - Connection strings updated in docker-compose, .env, CI CI/CD: - GitHub Actions workflow: all filter commands updated - Test database credentials updated Infrastructure: - Redis channel: planarchy:sse → capakraken:sse - Logger service name: planarchy-api → capakraken-api - Anonymization seed updated - Start/stop/restart scripts updated Test data: - Seed emails: @planarchy.dev → @capakraken.dev - E2E test credentials: all 11 spec files updated - Email defaults: @planarchy.app → @capakraken.app - localStorage keys: planarchy_* → capakraken_* Documentation: 30+ .md files updated Verification: - pnpm install: workspace resolution works - TypeScript: only pre-existing TS2589 (no new errors) - Engine: 310/310 tests pass - Staffing: 37/37 tests pass Co-Authored-By: claude-flow <ruv@ruv.net>
116 lines
2.9 KiB
TypeScript
116 lines
2.9 KiB
TypeScript
import { buildSplitAllocationReadModel } from "@capakraken/application";
|
|
import type { PrismaClient } from "@capakraken/db";
|
|
import { AllocationStatus } from "@capakraken/shared";
|
|
import { ROLE_BRIEF_SELECT } from "../db/selects.js";
|
|
|
|
export const PROJECT_PLANNING_ALLOCATION_INCLUDE = {
|
|
resource: {
|
|
select: {
|
|
id: true,
|
|
displayName: true,
|
|
eid: true,
|
|
chapter: true,
|
|
lcrCents: true,
|
|
availability: true,
|
|
},
|
|
},
|
|
project: {
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
shortCode: true,
|
|
orderType: true,
|
|
clientId: true,
|
|
budgetCents: true,
|
|
winProbability: true,
|
|
status: true,
|
|
startDate: true,
|
|
endDate: true,
|
|
staffingReqs: true,
|
|
responsiblePerson: true,
|
|
color: true,
|
|
},
|
|
},
|
|
roleEntity: {
|
|
select: ROLE_BRIEF_SELECT,
|
|
},
|
|
} as const;
|
|
|
|
export const PROJECT_PLANNING_DEMAND_INCLUDE = {
|
|
project: PROJECT_PLANNING_ALLOCATION_INCLUDE.project,
|
|
roleEntity: PROJECT_PLANNING_ALLOCATION_INCLUDE.roleEntity,
|
|
} as const;
|
|
|
|
export const PROJECT_PLANNING_ASSIGNMENT_INCLUDE = {
|
|
resource: PROJECT_PLANNING_ALLOCATION_INCLUDE.resource,
|
|
project: PROJECT_PLANNING_ALLOCATION_INCLUDE.project,
|
|
roleEntity: PROJECT_PLANNING_ALLOCATION_INCLUDE.roleEntity,
|
|
} as const;
|
|
|
|
/**
|
|
* Lighter resource select for timeline rendering (hot path).
|
|
* Omits `availability` which is only needed for budget/cost calculations.
|
|
*/
|
|
const TIMELINE_RESOURCE_SELECT = {
|
|
select: {
|
|
id: true,
|
|
displayName: true,
|
|
eid: true,
|
|
chapter: true,
|
|
lcrCents: true,
|
|
},
|
|
} as const;
|
|
|
|
export const TIMELINE_ASSIGNMENT_INCLUDE = {
|
|
resource: TIMELINE_RESOURCE_SELECT,
|
|
project: PROJECT_PLANNING_ALLOCATION_INCLUDE.project,
|
|
roleEntity: PROJECT_PLANNING_ALLOCATION_INCLUDE.roleEntity,
|
|
} as const;
|
|
|
|
type ProjectPlanningReadDbClient = Pick<
|
|
PrismaClient,
|
|
"demandRequirement" | "assignment"
|
|
>;
|
|
|
|
export interface LoadProjectPlanningReadModelInput {
|
|
projectId: string;
|
|
activeOnly?: boolean;
|
|
}
|
|
|
|
export async function loadProjectPlanningReadModel(
|
|
db: ProjectPlanningReadDbClient,
|
|
input: LoadProjectPlanningReadModelInput,
|
|
) {
|
|
const statusFilter = input.activeOnly
|
|
? { status: { not: AllocationStatus.CANCELLED } }
|
|
: {};
|
|
|
|
const [demandRequirements, assignments] = await Promise.all([
|
|
db.demandRequirement.findMany({
|
|
where: {
|
|
projectId: input.projectId,
|
|
...statusFilter,
|
|
},
|
|
include: PROJECT_PLANNING_DEMAND_INCLUDE,
|
|
orderBy: [{ startDate: "asc" }, { projectId: "asc" }],
|
|
}),
|
|
db.assignment.findMany({
|
|
where: {
|
|
projectId: input.projectId,
|
|
...statusFilter,
|
|
},
|
|
include: PROJECT_PLANNING_ASSIGNMENT_INCLUDE,
|
|
orderBy: [{ startDate: "asc" }, { resourceId: "asc" }],
|
|
}),
|
|
]);
|
|
|
|
return {
|
|
demandRequirements,
|
|
assignments,
|
|
readModel: buildSplitAllocationReadModel({
|
|
demandRequirements,
|
|
assignments,
|
|
}),
|
|
};
|
|
}
|