mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 06:52:04 +00:00
perf(auth): read the operator settings once per request
An app boot's /api/auth/me read the AppSettings singleton six times, each reader with its own few columns: the MFA policy, the Assistant switches, the module availability, the provider presence, the AI usage bounds and the reasoning controls. They now take their columns from one read, memoised for the request and read afresh inside a background job like the readers themselves. No answer changes.
This commit is contained in:
1 parent
e00943ff7f
commit
f8a88d1361
7 files changed
+68
-46
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { prisma } from "@/lib/db";
|
||||
import { readOperatorRow } from "@/lib/settings/operator-row";
|
||||
import { getEvent } from "@/lib/logging/context";
|
||||
import { memoizePerRequest } from "@/lib/request-cache";
|
||||
|
||||
@@ -57,16 +57,7 @@ export function loadAssistantSwitches(): Promise<AssistantFlagSet | null> {
|
||||
"assistant-flags",
|
||||
async () => {
|
||||
try {
|
||||
const settings = await prisma.appSettings.findUnique({
|
||||
where: { id: "singleton" },
|
||||
select: {
|
||||
assistantEnabled: true,
|
||||
assistantCoachEnabled: true,
|
||||
assistantBriefingEnabled: true,
|
||||
assistantInsightStatusEnabled: true,
|
||||
assistantDocumentAiEnabled: true,
|
||||
},
|
||||
});
|
||||
const settings = await readOperatorRow();
|
||||
return resolveAssistantFlags({
|
||||
enabled: settings?.assistantEnabled ?? true,
|
||||
coach: settings?.assistantCoachEnabled ?? true,
|
||||
|
||||
Reference in new issue
Block a user