teqo/scripts/regenerate-municipality-catalog-snapshot.mjs
Francisco Ignácio Fontoura Solla e2724c10da Remodel the campaign vertical from Praça to Município
Rename the operational unit "Praça"/"Núcleo" to "Município" (code identifier
`municipality`) and land the 2026-07-23 course changes:

- New `candidate` role with unrestricted visibility (`isCampaignStaff` now
  includes it) alongside coordinator/advisor; leader is locked down to the
  supporter contact tool only.
- Demandas become staff-only; dobradinhas modeled via a `stateDeputy` entity.
- Camaçari consolidated to a single município (ZE 170/171 aggregated);
  Salvador keeps its 19 zone municípios.
- Map moves to the staff dashboard; `/campanha/municipios` is list/overview.
- Vote pledges keep the declared vs estimated (scenario) asymmetry; leaders
  never see estimates.

Destructive migration for the campaign vertical (drops nucleus/plaza-era
tables, wipes campaign rows, seeds 435 municípios). Public-site data untouched.

Includes the post-delivery /simplify cleanups: shared reloadStaffActor /
reloadCoordinatorActor helpers, req.context cache for getFreshCampaignUser,
parallelized dashboard loads, candidate dashboard-copy fix, and dead
leader-dashboard / roleKind code removal.
2026-07-23 21:36:20 -03:00

38 lines
1.1 KiB
JavaScript

import { createHash } from 'node:crypto'
import { writeFileSync } from 'node:fs'
import { municipalityCatalog, ZONE_MUNICIPALITY_CITIES } from '../src/lib/municipalityCatalog.ts'
const entries = municipalityCatalog.map(
({ slug, name, kind, city, region, ibgeCode, tseCityCode, zoneNumber, tseZones }) => ({
slug,
name,
kind,
city,
region,
ibgeCode,
tseCityCode,
...(zoneNumber === undefined ? {} : { zoneNumber }),
tseZones: [...tseZones],
}),
)
const rows = entries
.map(
(entry) =>
`P\t${entry.slug}\t${entry.name}\t${entry.kind}\t${entry.city}\t${entry.zoneNumber ?? ''}\n`,
)
.join('')
const snapshot = {
description:
'Frozen snapshot of the derived municipality catalog (slug/name identity must stay stable).',
generatedFrom: 'src/lib/municipalityCatalog.ts',
municipalityCount: entries.length,
zoneMunicipalityCities: [...ZONE_MUNICIPALITY_CITIES],
identitySha256: createHash('sha256').update(rows).digest('hex'),
entries,
}
writeFileSync(
'tests/fixtures/municipality-catalog.snapshot.json',
`${JSON.stringify(snapshot, null, 2)}\n`,
)
console.log(`Wrote ${entries.length} entries`)