feat: Sprint 1 — staffing assign, dashboard cache, bulk ops, notifications
Staffing "Assign" Button: - Inline assignment form on each suggestion card in StaffingPanel - Pre-fills project, dates, hours from search criteria - 1-click confirm creates allocation with PROPOSED status - Success/error toasts, removes assigned suggestions from list Dashboard Redis Caching: - New cache utility (packages/api/src/lib/cache.ts) with get/set/invalidate - All 5 dashboard queries wrapped with 60s TTL cache-aside pattern - Auto-invalidation on allocation + project mutations (fire-and-forget) - Graceful fallthrough to DB if Redis unavailable Bulk Operations: - CSV export for selected resources and projects (apps/web/src/lib/csv-export.ts) - Project batch delete mutation with cascade (assignments, demands, rules) - Export/Delete buttons added to BatchActionBar on both list pages Budget Overrun Notifications: - checkBudgetThresholds() alerts at 80% (HIGH) and 100% (URGENT) - Called after every allocation mutation, duplicate-safe - Targets ADMIN + MANAGER users with SSE delivery Estimate Approval Reminders: - checkPendingEstimateReminders() finds SUBMITTED versions > 3 days old - Cron endpoint: GET /api/cron/estimate-reminders (optional CRON_SECRET auth) - Creates in-app REMINDER notifications, duplicate-safe Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -12,6 +12,7 @@ import { buildDynamicFieldWhereClauses } from "./custom-field-filters.js";
|
||||
import { loadProjectPlanningReadModel } from "./project-planning-read-model.js";
|
||||
import { adminProcedure, controllerProcedure, createTRPCRouter, managerProcedure, protectedProcedure, requirePermission } from "../trpc.js";
|
||||
import { createDalleClient, isDalleConfigured, parseAiError } from "../ai-client.js";
|
||||
import { invalidateDashboardCache } from "../lib/cache.js";
|
||||
|
||||
const MAX_COVER_SIZE = 4 * 1024 * 1024; // 4 MB base64 string length limit (client compresses before upload)
|
||||
|
||||
@@ -155,6 +156,7 @@ export const projectRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
|
||||
void invalidateDashboardCache();
|
||||
return project;
|
||||
}),
|
||||
|
||||
@@ -207,6 +209,7 @@ export const projectRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
|
||||
void invalidateDashboardCache();
|
||||
return updated;
|
||||
}),
|
||||
|
||||
@@ -214,10 +217,12 @@ export const projectRouter = createTRPCRouter({
|
||||
.input(z.object({ id: z.string(), status: z.nativeEnum(ProjectStatus) }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
requirePermission(ctx, PermissionKey.MANAGE_PROJECTS);
|
||||
return ctx.db.project.update({
|
||||
const result = await ctx.db.project.update({
|
||||
where: { id: input.id },
|
||||
data: { status: input.status },
|
||||
});
|
||||
void invalidateDashboardCache();
|
||||
return result;
|
||||
}),
|
||||
|
||||
batchUpdateStatus: managerProcedure
|
||||
@@ -244,6 +249,7 @@ export const projectRouter = createTRPCRouter({
|
||||
},
|
||||
});
|
||||
|
||||
void invalidateDashboardCache();
|
||||
return { count: updated.length };
|
||||
}),
|
||||
|
||||
@@ -349,9 +355,50 @@ export const projectRouter = createTRPCRouter({
|
||||
});
|
||||
});
|
||||
|
||||
void invalidateDashboardCache();
|
||||
return { id: input.id, name: project.name };
|
||||
}),
|
||||
|
||||
batchDelete: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
ids: z.array(z.string()).min(1).max(50),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const projects = await ctx.db.project.findMany({
|
||||
where: { id: { in: input.ids } },
|
||||
select: { id: true, name: true, shortCode: true },
|
||||
});
|
||||
|
||||
if (projects.length === 0) {
|
||||
throw new TRPCError({ code: "NOT_FOUND", message: "No projects found" });
|
||||
}
|
||||
|
||||
await ctx.db.$transaction(async (tx) => {
|
||||
const ids = projects.map((p) => p.id);
|
||||
await tx.assignment.deleteMany({ where: { projectId: { in: ids } } });
|
||||
await tx.demandRequirement.deleteMany({ where: { projectId: { in: ids } } });
|
||||
await tx.calculationRule.updateMany({
|
||||
where: { projectId: { in: ids } },
|
||||
data: { projectId: null },
|
||||
});
|
||||
await tx.project.deleteMany({ where: { id: { in: ids } } });
|
||||
await tx.auditLog.create({
|
||||
data: {
|
||||
entityType: "Project",
|
||||
entityId: ids.join(","),
|
||||
action: "DELETE",
|
||||
...(ctx.dbUser?.id ? { userId: ctx.dbUser.id } : {}),
|
||||
changes: { before: projects } as never,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
void invalidateDashboardCache();
|
||||
return { count: projects.length };
|
||||
}),
|
||||
|
||||
// ─── Cover Art ──────────────────────────────────────────────────────────────
|
||||
|
||||
generateCover: managerProcedure
|
||||
|
||||
Reference in New Issue
Block a user