From 76597292c99561aeca9eb0ae1a72b52ee6630622 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 2 Aug 2026 19:05:41 +0000 Subject: [PATCH] =?UTF-8?q?B129=20=E2=80=94=20Simplify=20cleanup=20after?= =?UTF-8?q?=20overview=20removal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix duplicated JSDoc, trim stale int test, defer perf follow-ups in impl plan. Co-authored-by: Francisco Solla --- .../remover-overview-lista-municipios-impl.md | 1 + .../municipality/municipalityPageData.ts | 3 +- tests/int/municipalityPageData.int.spec.ts | 37 +------------------ 3 files changed, 4 insertions(+), 37 deletions(-) diff --git a/docs/plans/remover-overview-lista-municipios-impl.md b/docs/plans/remover-overview-lista-municipios-impl.md index 3289ab98..e4791b21 100644 --- a/docs/plans/remover-overview-lista-municipios-impl.md +++ b/docs/plans/remover-overview-lista-municipios-impl.md @@ -41,6 +41,7 @@ Appetite restante: remoção cirúrgica (sem redesign) - Redesenhar `loading.tsx` (fora do aceite). - Tocar `SupporterListOverview` ou dashboard. +- **Defer:** escopo de `loadMunicipalityGoalCoverageBundle` ao page slice quando `isPagedByPayload` (gatilho: perf review pós-B129); skip `aggregateByScenario` no loader de lista (gatilho: 2º consumidor de rows-only). ## Riscos e mitigação diff --git a/src/utilities/municipality/municipalityPageData.ts b/src/utilities/municipality/municipalityPageData.ts index 5dea27d4..48a8367e 100644 --- a/src/utilities/municipality/municipalityPageData.ts +++ b/src/utilities/municipality/municipalityPageData.ts @@ -87,8 +87,7 @@ type MunicipalityFacetRow = Pick * class is derived from the committed TSE artifact, not stored), so every * place that would otherwise trust `where` — the page query and the facets — * has to apply this predicate itself. Returns `null` when no class is selected, - * when no class is selected, which is also the signal to keep the cheap - * database-paginated path. + * which is also the signal to keep the cheap database-paginated path. */ const territorialClassFilterPredicate = ( state: MunicipalityListState, diff --git a/tests/int/municipalityPageData.int.spec.ts b/tests/int/municipalityPageData.int.spec.ts index 755ba7d1..ffc2527c 100644 --- a/tests/int/municipalityPageData.int.spec.ts +++ b/tests/int/municipalityPageData.int.spec.ts @@ -9,8 +9,6 @@ import { territorialClassSortWeight } from '@/lib/territorialClassSortWeight' import config from '@/payload.config' import { loadMunicipalityListPageBundle } from '@/utilities/municipality/municipalityPageData' import { computeMunicipalityTerritorialClass } from '@/utilities/municipality/municipalityTerritorialClass' -import { aggregatePledgesByMunicipality } from '@/utilities/votePledgeData' -import { rollupMunicipalityStaffVotes } from '@/utilities/votePledgeViews' import { installCampaignFixtures } from '../helpers/campaignFixtures' @@ -36,43 +34,12 @@ describe('loadMunicipalityListPageBundle', () => { expect(bundle.totalDocs).toBe(0) }) - it('rolls up staffVoteTotal from expectedVotes when no pledge overrides apply', async () => { + it('includes 2022 vote position on list rows', async () => { const fixtures = campaignFixtures() const coordinator = await fixtures.createCampaignUser('coordinator') const municipality = await fixtures.getMunicipality() fixtures.touchMunicipality(municipality.id) - await payload.update({ - collection: 'municipality', - id: municipality.id, - data: { expectedVotes: { pessimistic: null, central: 1_500, optimistic: null } }, - depth: 0, - overrideAccess: true, - }) - - const contact = await fixtures.createContact() - const leadership = await fixtures.createLeadership({ - contact: contact.id, - municipalities: [municipality.id], - supportStatus: 'engajado', - }) - await fixtures.createVotePledge({ - leadership: leadership.id, - municipality: municipality.id, - declaredVotes: 80, - estimatedVotes: { pessimistic: null, central: 120, optimistic: null }, - }) - - const refreshedMunicipality = await payload.findByID({ - collection: 'municipality', - id: municipality.id, - depth: 0, - overrideAccess: true, - }) - const aggregates = await aggregatePledgesByMunicipality(payload, [municipality.id]) - const rollup = rollupMunicipalityStaffVotes([refreshedMunicipality], aggregates) - expect(rollup.staffVoteTotal).toBe(1_500) - const bundle = await loadMunicipalityListPageBundle(payload, coordinator, { q: municipality.name, }) @@ -278,7 +245,7 @@ describe('loadMunicipalityListPageBundle', () => { * cannot be a Payload constraint. The bundle must still agree with itself — * rows and `totalDocs` counting the filtered scope. */ - it('filters by the derived territorial class and keeps the overview honest', async () => { + it('filters by the derived territorial class and keeps totals honest', async () => { const fixtures = campaignFixtures() const coordinator = await fixtures.createCampaignUser('coordinator')