chore(repo): initialize planarchy workspace

This commit is contained in:
2026-03-14 14:31:09 +01:00
commit dd55d0e78b
769 changed files with 166461 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
import { z } from "zod";
import { createTRPCRouter, protectedProcedure, controllerProcedure } from "../trpc.js";
import {
getDashboardChargeabilityOverview,
getDashboardDemand,
getDashboardOverview,
getDashboardPeakTimes,
getDashboardTopValueResources,
} from "@planarchy/application";
export const dashboardRouter = createTRPCRouter({
getOverview: protectedProcedure.query(({ ctx }) => getDashboardOverview(ctx.db)),
getPeakTimes: protectedProcedure
.input(
z.object({
startDate: z.string().datetime(),
endDate: z.string().datetime(),
granularity: z.enum(["week", "month"]).default("month"),
groupBy: z.enum(["project", "chapter", "resource"]).default("project"),
}),
)
.query(({ ctx, input }) =>
getDashboardPeakTimes(ctx.db, {
startDate: new Date(input.startDate),
endDate: new Date(input.endDate),
granularity: input.granularity,
groupBy: input.groupBy,
}),
),
getTopValueResources: protectedProcedure
.input(z.object({ limit: z.number().int().min(1).max(50).default(10) }))
.query(({ ctx, input }) =>
getDashboardTopValueResources(ctx.db, {
limit: input.limit,
userRole:
(ctx.session.user as { role?: string } | undefined)?.role ?? "USER",
}),
),
getDemand: protectedProcedure
.input(
z.object({
startDate: z.string().datetime(),
endDate: z.string().datetime(),
groupBy: z.enum(["project", "person", "chapter"]).default("project"),
}),
)
.query(({ ctx, input }) =>
getDashboardDemand(ctx.db, {
startDate: new Date(input.startDate),
endDate: new Date(input.endDate),
groupBy: input.groupBy,
}),
),
getChargeabilityOverview: controllerProcedure
.input(
z.object({
topN: z.number().int().min(1).max(50).default(10),
watchlistThreshold: z.number().default(15),
}),
)
.query(({ ctx, input }) =>
getDashboardChargeabilityOverview(ctx.db, {
topN: input.topN,
watchlistThreshold: input.watchlistThreshold,
}),
),
});