Files
CapaKraken/packages/api/src/router/timeline-allocation-procedure-support.ts
T

26 lines
747 B
TypeScript

import type { PrismaClient } from "@capakraken/db";
import { emitAllocationUpdated } from "../sse/event-bus.js";
import { applyTimelineBatchAllocationShift } from "./timeline-allocation-shift-support.js";
export async function shiftTimelineAllocations(
db: PrismaClient,
input: Omit<Parameters<typeof applyTimelineBatchAllocationShift>[0], "db">,
) {
const results = await applyTimelineBatchAllocationShift({
db,
allocationIds: input.allocationIds,
daysDelta: input.daysDelta,
mode: input.mode,
});
for (const allocation of results) {
emitAllocationUpdated({
id: allocation.id,
projectId: allocation.projectId,
resourceId: allocation.resourceId,
});
}
return { count: results.length };
}