[Debt] Reduce campaign route and recipient UI duplication after address integration #56

Closed
opened 2026-07-13 17:21:11 +02:00 by zemion · 1 comment
Owner

Created from add-ideas/govoplan#3 after triaging /mnt/DATA/git/govoplan/audit-reports/govoplan-full-20260711-1857/jscpd/jscpd-report.json.

Evidence

jscpd reports campaign-local source duplication, including:

  • govoplan_campaign/backend/router.py lines 1327-1353 and 1374-1400
  • webui/src/features/campaigns/RecipientDataPage.tsx lines 350-375 and RecipientDetailsPage.tsx lines 154-179
  • govoplan_campaign/backend/campaign/models.py lines 126-150 and govoplan_mail/backend/schemas.py lines 31-56

This area is changing because campaign now integrates address lookup/snapshots and mail delivery contracts, so repeated recipient/address/message structures are likely to drift.

Desired Shape

Extract campaign-local helpers/components where behavior is the same, and define explicit shared contracts where campaign/mail structures represent the same stable concept.

Acceptance Criteria

  • Repeated campaign route logic is factored into a helper without changing endpoint behavior.
  • Repeated recipient UI display/edit fragments become a small campaign component or documented intentional variants.
  • Campaign/mail schema overlap is reviewed for a shared contract versus module-local semantics.
  • Relevant campaign backend/WebUI tests pass.
Created from add-ideas/govoplan#3 after triaging `/mnt/DATA/git/govoplan/audit-reports/govoplan-full-20260711-1857/jscpd/jscpd-report.json`. ## Evidence jscpd reports campaign-local source duplication, including: - `govoplan_campaign/backend/router.py` lines 1327-1353 and 1374-1400 - `webui/src/features/campaigns/RecipientDataPage.tsx` lines 350-375 and `RecipientDetailsPage.tsx` lines 154-179 - `govoplan_campaign/backend/campaign/models.py` lines 126-150 and `govoplan_mail/backend/schemas.py` lines 31-56 This area is changing because campaign now integrates address lookup/snapshots and mail delivery contracts, so repeated recipient/address/message structures are likely to drift. ## Desired Shape Extract campaign-local helpers/components where behavior is the same, and define explicit shared contracts where campaign/mail structures represent the same stable concept. ## Acceptance Criteria - Repeated campaign route logic is factored into a helper without changing endpoint behavior. - Repeated recipient UI display/edit fragments become a small campaign component or documented intentional variants. - Campaign/mail schema overlap is reviewed for a shared contract versus module-local semantics. - Relevant campaign backend/WebUI tests pass.
Author
Owner

Codex State: done

Summary

  • Factored repeated campaign version route response assembly into shared helpers for mutation, audit emission, response conversion, and existing error mapping.
  • Factored shared campaign job list query parameters into a FastAPI dependency so normal and delta job endpoints keep the same query string without duplicated signatures.
  • Moved legacy split mail transport credential normalization into govoplan_core.mail.config and reused it from campaign and mail.
  • Extracted shared recipient-import draft materialization and the repeated recipient page frame into campaign WebUI helpers/components.

Changed Files

  • src/govoplan_campaign/backend/router.py
  • src/govoplan_campaign/backend/campaign/models.py
  • webui/src/features/campaigns/utils/bulkImport.ts
  • webui/src/features/campaigns/RecipientDataPage.tsx
  • webui/src/features/campaigns/RecipientDetailsPage.tsx
  • webui/src/features/campaigns/components/CampaignDraftPageScaffold.tsx
  • ../govoplan-core/src/govoplan_core/mail/config.py
  • ../govoplan-core/tests/test_mail_config.py
  • ../govoplan-mail/src/govoplan_mail/backend/config.py
  • ../govoplan-mail/src/govoplan_mail/backend/schemas.py

Verification

  • python -m ruff check --ignore E402 touched backend/core/mail files: passed; E402 ignored for existing lower-section imports in campaign router
  • python -m py_compile touched backend/core/mail files: passed
  • python -m unittest discover -s tests (govoplan-campaign): 2 passed
  • python -m unittest tests.test_mail_config (govoplan-core): 1 passed
  • npm run test:import-utils (govoplan-campaign/webui): passed
  • TypeScript transpile syntax check for touched TS/TSX files: passed
  • npx --yes jscpd --absolute --min-tokens 80 focused campaign/mail files: Found 0 clones
  • git diff --check in campaign/core/mail touched files: passed
## Codex State: done ### Summary - Factored repeated campaign version route response assembly into shared helpers for mutation, audit emission, response conversion, and existing error mapping. - Factored shared campaign job list query parameters into a FastAPI dependency so normal and delta job endpoints keep the same query string without duplicated signatures. - Moved legacy split mail transport credential normalization into govoplan_core.mail.config and reused it from campaign and mail. - Extracted shared recipient-import draft materialization and the repeated recipient page frame into campaign WebUI helpers/components. ### Changed Files - `src/govoplan_campaign/backend/router.py` - `src/govoplan_campaign/backend/campaign/models.py` - `webui/src/features/campaigns/utils/bulkImport.ts` - `webui/src/features/campaigns/RecipientDataPage.tsx` - `webui/src/features/campaigns/RecipientDetailsPage.tsx` - `webui/src/features/campaigns/components/CampaignDraftPageScaffold.tsx` - `../govoplan-core/src/govoplan_core/mail/config.py` - `../govoplan-core/tests/test_mail_config.py` - `../govoplan-mail/src/govoplan_mail/backend/config.py` - `../govoplan-mail/src/govoplan_mail/backend/schemas.py` ### Verification - `python -m ruff check --ignore E402 touched backend/core/mail files: passed; E402 ignored for existing lower-section imports in campaign router` - `python -m py_compile touched backend/core/mail files: passed` - `python -m unittest discover -s tests (govoplan-campaign): 2 passed` - `python -m unittest tests.test_mail_config (govoplan-core): 1 passed` - `npm run test:import-utils (govoplan-campaign/webui): passed` - `TypeScript transpile syntax check for touched TS/TSX files: passed` - `npx --yes jscpd --absolute --min-tokens 80 focused campaign/mail files: Found 0 clones` - `git diff --check in campaign/core/mail touched files: passed`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: add-ideas/govoplan-campaign#56
No description provided.