Merge branch 'worktree-agent-aed43cff'
This commit is contained in:
@@ -55,3 +55,34 @@ export const RESOURCE_DIRECTORY_SELECT = {
|
|||||||
chapter: true,
|
chapter: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicit select for the resource list endpoint (listStaff).
|
||||||
|
* Omits large JSONB columns that are unused in all list consumers:
|
||||||
|
* - availability (~several KB per row, only needed for scheduling calculations)
|
||||||
|
* - valueScoreBreakdown (JSON, only needed in detail/dashboard views)
|
||||||
|
* - aiSummary / aiSummaryUpdatedAt / skillMatrixUpdatedAt / portfolioUrl
|
||||||
|
* This keeps skills and dynamicFields because they are rendered in the resource table.
|
||||||
|
*/
|
||||||
|
export const RESOURCE_LIST_SELECT = {
|
||||||
|
id: true,
|
||||||
|
eid: true,
|
||||||
|
displayName: true,
|
||||||
|
email: true,
|
||||||
|
chapter: true,
|
||||||
|
lcrCents: true,
|
||||||
|
ucrCents: true,
|
||||||
|
currency: true,
|
||||||
|
chargeabilityTarget: true,
|
||||||
|
skills: true,
|
||||||
|
dynamicFields: true,
|
||||||
|
blueprintId: true,
|
||||||
|
isActive: true,
|
||||||
|
roleId: true,
|
||||||
|
federalState: true,
|
||||||
|
valueScore: true,
|
||||||
|
rolledOff: true,
|
||||||
|
departed: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
} as const;
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { FieldType, ResourceType } from "@capakraken/shared";
|
|||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import {
|
import {
|
||||||
ROLE_BRIEF_SELECT,
|
|
||||||
RESOURCE_DIRECTORY_SELECT,
|
RESOURCE_DIRECTORY_SELECT,
|
||||||
RESOURCE_IDENTIFIER_DETAIL_SELECT,
|
RESOURCE_IDENTIFIER_DETAIL_SELECT,
|
||||||
RESOURCE_IDENTIFIER_SELECT,
|
RESOURCE_IDENTIFIER_SELECT,
|
||||||
|
RESOURCE_LIST_SELECT,
|
||||||
RESOURCE_SUMMARY_DETAIL_SELECT,
|
RESOURCE_SUMMARY_DETAIL_SELECT,
|
||||||
RESOURCE_SUMMARY_SELECT,
|
RESOURCE_SUMMARY_SELECT,
|
||||||
|
ROLE_BRIEF_SELECT,
|
||||||
} from "../db/selects.js";
|
} from "../db/selects.js";
|
||||||
import { buildDynamicFieldWhereClauses } from "./custom-field-filters.js";
|
import { buildDynamicFieldWhereClauses } from "./custom-field-filters.js";
|
||||||
import {
|
import {
|
||||||
@@ -167,7 +168,8 @@ export async function listStaffResources(
|
|||||||
const rawResources = await (includeRoles
|
const rawResources = await (includeRoles
|
||||||
? ctx.db.resource.findMany({
|
? ctx.db.resource.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
select: {
|
||||||
|
...RESOURCE_LIST_SELECT,
|
||||||
resourceRoles: {
|
resourceRoles: {
|
||||||
include: { role: { select: ROLE_BRIEF_SELECT } },
|
include: { role: { select: ROLE_BRIEF_SELECT } },
|
||||||
},
|
},
|
||||||
@@ -176,6 +178,7 @@ export async function listStaffResources(
|
|||||||
})
|
})
|
||||||
: ctx.db.resource.findMany({
|
: ctx.db.resource.findMany({
|
||||||
where,
|
where,
|
||||||
|
select: RESOURCE_LIST_SELECT,
|
||||||
orderBy: [{ displayName: "asc" }, { id: "asc" }],
|
orderBy: [{ displayName: "asc" }, { id: "asc" }],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -264,13 +267,17 @@ export async function listStaffResources(
|
|||||||
includeRoles
|
includeRoles
|
||||||
? ctx.db.resource.findMany({
|
? ctx.db.resource.findMany({
|
||||||
...baseQuery,
|
...baseQuery,
|
||||||
include: {
|
select: {
|
||||||
|
...RESOURCE_LIST_SELECT,
|
||||||
resourceRoles: {
|
resourceRoles: {
|
||||||
include: { role: { select: ROLE_BRIEF_SELECT } },
|
include: { role: { select: ROLE_BRIEF_SELECT } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: ctx.db.resource.findMany(baseQuery),
|
: ctx.db.resource.findMany({
|
||||||
|
...baseQuery,
|
||||||
|
select: RESOURCE_LIST_SELECT,
|
||||||
|
}),
|
||||||
ctx.db.resource.count({ where }),
|
ctx.db.resource.count({ where }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user