perf(api): eliminate 3 N+1 query patterns
- timeline-holiday-load-support: deduplicate getResolvedCalendarHolidays by location key so resources sharing the same country/state/city resolve holidays once instead of per-resource - rate-card-lookup: add lookupRatesBatch that loads rate card lines once and scores locally per demand line, replacing per-line DB round-trips in estimate-demand-lines autoFillDemandLineRates - config-readmodels: include _count in utilization-category list query instead of calling getById per category for project counts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-12
@@ -43,17 +43,9 @@ describe("assistant master data management and utilization read tools", () => {
|
||||
description: "Client work",
|
||||
isActive: true,
|
||||
sortOrder: 1,
|
||||
_count: { projects: 3 },
|
||||
},
|
||||
]),
|
||||
findUnique: vi.fn().mockResolvedValue({
|
||||
id: "util_billable",
|
||||
code: "BILLABLE",
|
||||
name: "Billable",
|
||||
description: "Client work",
|
||||
isActive: true,
|
||||
sortOrder: 1,
|
||||
_count: { projects: 3 },
|
||||
}),
|
||||
},
|
||||
};
|
||||
const ctx = createToolContext(db, {
|
||||
@@ -71,9 +63,6 @@ describe("assistant master data management and utilization read tools", () => {
|
||||
expect(db.utilizationCategory.findMany).toHaveBeenCalledWith({
|
||||
where: {},
|
||||
orderBy: { sortOrder: "asc" },
|
||||
});
|
||||
expect(db.utilizationCategory.findUnique).toHaveBeenCalledWith({
|
||||
where: { id: "util_billable" },
|
||||
include: { _count: { select: { projects: true } } },
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user