mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-16 03:03:06 +00:00
- committed artifact src/lib/electionAggregates/bahia-federal-baseline.json (Solla nominal + federal T1 valid votes per catalog municipality × TSE year, Salvador split by zone) generated by pnpm build:election-aggregates from the locally seeded TSE data; typed loader src/lib/bahiaElectionAggregates.ts; snapshot spec pins artifact ↔ catalog ↔ baseline ticket - map bundle: historical years now read the artifact (was 6 statewide city×zone scans per dashboard visit); compare mode keeps only the OTHER candidate on the DB path (Solla side from the artifact) - loadMunicipalityScope (React cache()): one municipality find + pledge aggregate per request shared by dashboard KPIs, map bundle, and the municípios list overview (was 2-3 duplicate loads) - unstable_cache + election-tse tag on the immutable elections-tab loaders (baseline, candidate comparison, candidate options); tag added to the /api/revalidate allowlist — runbook: re-seed then bust the tag - municipalityMapContract.ts: client-safe map vocabulary/bundle types so the client panel no longer imports the server data module (build had pulled @payload-config into the client graph); municipalityMapData is server-only and re-exports the contract; PLAZA_MAP_* renamed to MUNICIPALITY_MAP_* - petition generateStaticParams enumerates bare ids (getPetitionIds)
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { ELECTION_TSE_CACHE_TAG } from '@/utilities/electionCache'
|
|
import { getGlobalCacheTag } from '@/utilities/globals'
|
|
|
|
export const REVALIDATE_POSTS_TAG = 'posts' as const
|
|
|
|
export const REVALIDATE_PRIVACY_POLICY_CACHE_TAG = getGlobalCacheTag('privacy-policy')
|
|
|
|
const ALLOWED_REVALIDATE_TAGS = [
|
|
REVALIDATE_POSTS_TAG,
|
|
REVALIDATE_PRIVACY_POLICY_CACHE_TAG,
|
|
ELECTION_TSE_CACHE_TAG,
|
|
] as const
|
|
|
|
export type AllowedRevalidateTag = (typeof ALLOWED_REVALIDATE_TAGS)[number]
|
|
|
|
const allowedTagSet = new Set<string>(ALLOWED_REVALIDATE_TAGS)
|
|
|
|
export type ResolveRevalidateTagResult =
|
|
| { ok: true; tag: AllowedRevalidateTag }
|
|
| { ok: false; error: string }
|
|
|
|
const isAllowedRevalidateTag = (tag: string): tag is AllowedRevalidateTag =>
|
|
allowedTagSet.has(tag)
|
|
|
|
export const resolveRevalidateTag = (
|
|
queryTag: string | null | undefined,
|
|
bodyTag: string | null | undefined,
|
|
): ResolveRevalidateTagResult => {
|
|
const requested = queryTag ?? bodyTag
|
|
|
|
if (requested == null || requested === '') {
|
|
return { ok: true, tag: REVALIDATE_POSTS_TAG }
|
|
}
|
|
|
|
if (!isAllowedRevalidateTag(requested)) {
|
|
return {
|
|
ok: false,
|
|
error: `Unknown tag. Allowed: ${ALLOWED_REVALIDATE_TAGS.join(', ')}`,
|
|
}
|
|
}
|
|
|
|
return { ok: true, tag: requested }
|
|
}
|