feat(platform): checkpoint current implementation state
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import type { PrismaClient } from "@capakraken/db";
|
||||
import { emitAllocationUpdated } from "../sse/event-bus.js";
|
||||
import {
|
||||
emitAllocationCreated,
|
||||
emitAllocationDeleted,
|
||||
emitAllocationUpdated,
|
||||
} from "../sse/event-bus.js";
|
||||
import {
|
||||
createTimelineBatchQuickAssignments,
|
||||
createTimelineQuickAssignment,
|
||||
} from "./timeline-allocation-assignment-procedure-support.js";
|
||||
import {
|
||||
carveTimelineAllocationRange,
|
||||
extractTimelineAllocationFragment,
|
||||
} from "./timeline-allocation-fragment-support.js";
|
||||
import { applyTimelineInlineAllocationUpdate } from "./timeline-allocation-inline-support.js";
|
||||
import { shiftTimelineAllocations } from "./timeline-allocation-procedure-support.js";
|
||||
|
||||
@@ -67,3 +75,68 @@ export async function applyTimelineAllocationBatchShiftMutation(
|
||||
) {
|
||||
return shiftTimelineAllocations(db, input);
|
||||
}
|
||||
|
||||
export async function carveTimelineAllocationRangeMutation(input: {
|
||||
db: PrismaClient;
|
||||
allocationId: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
}) {
|
||||
const result = await carveTimelineAllocationRange({
|
||||
db: input.db,
|
||||
allocationId: input.allocationId,
|
||||
startDate: input.startDate,
|
||||
endDate: input.endDate,
|
||||
});
|
||||
|
||||
for (const allocationId of result.updatedAllocationIds) {
|
||||
emitAllocationUpdated({
|
||||
id: allocationId,
|
||||
projectId: result.projectId,
|
||||
resourceId: result.resourceId,
|
||||
});
|
||||
}
|
||||
for (const allocationId of result.createdAllocationIds) {
|
||||
emitAllocationCreated({
|
||||
id: allocationId,
|
||||
projectId: result.projectId,
|
||||
resourceId: result.resourceId,
|
||||
});
|
||||
}
|
||||
for (const allocationId of result.deletedAllocationIds) {
|
||||
emitAllocationDeleted(allocationId, result.projectId, result.resourceId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function extractTimelineAllocationFragmentMutation(input: {
|
||||
db: PrismaClient;
|
||||
allocationId: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
}) {
|
||||
const result = await extractTimelineAllocationFragment({
|
||||
db: input.db,
|
||||
allocationId: input.allocationId,
|
||||
startDate: input.startDate,
|
||||
endDate: input.endDate,
|
||||
});
|
||||
|
||||
for (const allocationId of result.updatedAllocationIds) {
|
||||
emitAllocationUpdated({
|
||||
id: allocationId,
|
||||
projectId: result.projectId,
|
||||
resourceId: result.resourceId,
|
||||
});
|
||||
}
|
||||
for (const allocationId of result.createdAllocationIds) {
|
||||
emitAllocationCreated({
|
||||
id: allocationId,
|
||||
projectId: result.projectId,
|
||||
resourceId: result.resourceId,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user