refactor(18): IN-01/IN-02 reuse fetched row for GET timezone fallback
The GET /config/timezone handler SELECTed app_config then, on the unset path, called getHouseholdTimezone(db) which re-issued the identical SELECT before falling back (IN-01). The fallback decision also lived in two places (IN-02). Route the handler through the centralized resolveHouseholdTimezone(row?.value) added for WR-01: no redundant round-trip, single source for the D-06 policy. Behavior unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d168da71cf
commit
692fe2ad9a
@@ -27,7 +27,7 @@ import { eq, sql } from 'drizzle-orm';
|
||||
import { db } from '../db/client.js';
|
||||
import { users, memberCredentials, calendars, appConfig } from '../db/schema.js';
|
||||
import { requireAdmin } from '../lib/requireAdmin.js';
|
||||
import { isValidIanaTimezone, getHouseholdTimezone } from '../lib/householdTimezone.js';
|
||||
import { isValidIanaTimezone, resolveHouseholdTimezone } from '../lib/householdTimezone.js';
|
||||
import {
|
||||
validateEncryptAndStoreCredential,
|
||||
CredentialValidationError,
|
||||
@@ -205,9 +205,9 @@ adminRouter.get('/config/timezone', async (c) => {
|
||||
.limit(1);
|
||||
|
||||
const isExplicitlySet = row?.value != null;
|
||||
const timezone = isExplicitlySet
|
||||
? (row.value as string)
|
||||
: await getHouseholdTimezone(db);
|
||||
// IN-01/IN-02: reuse the row we just SELECTed and let the centralized accessor apply
|
||||
// the D-06 fallback — no second app_config round-trip, single source for the policy.
|
||||
const timezone = resolveHouseholdTimezone(row?.value ?? null);
|
||||
|
||||
return c.json({ timezone, isExplicitlySet });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user