Skip to content

Keep the abroad section addresses in the API - #284

Merged
hkdobrev merged 1 commit into
mainfrom
feature/abroad-sections-list-and-addresses
Oct 26, 2026
Merged

hkdobrev merged 1 commit into
mainfrom
feature/abroad-sections-list-and-addresses

Conversation

@hkdobrev

Copy link
Copy Markdown
Member

Steps 3–4 of keeping the abroad section addresses in the API. It builds on #282 (the address column). Replaces #283, which was closed when its base branch was deleted.

GET /sections/abroad (public, Cache-Control: public, max-age=300)

  • Every 32* section: {id, code, place, address, town: {id, name}, country: {code, name}}.
  • The site will read addresses from here instead of its generated copy of the МВнР table.

PATCH /sections/abroad/addresses (admin, Manage Section) and npm run sections:update-abroad-addresses -- file.csv [--dry-run]

  • Input: a CSV file (section_id/id/№ на секция + address/Адрес; other columns ignored) or JSON {"sections":[{"id","address"}]}.
  • Writes only sections.address of existing 32* sections, inside a transaction under an advisory lock.
  • Unknown ids are reported, never created. Nothing is deleted. Domestic ids and empty or conflicting addresses get a 400.
  • Report: {dryRun, received, updated:[{id,from,to}], unchanged, unknown}. With dryRun everything is rolled back.

Also

  • scripts/sections-preprocess/mfa_abroad_addresses.py: the МВнР xlsx → CSV (moved from the site's scripts/mfa-abroad-addresses.py). On the current table (upload 166450) it gives 613 sections, all with an address, identical to the site's data file.
  • docs/abroad-addresses.md.
  • The controller is registered before SectionsController, so /sections/abroad is not read as /sections/:section.

Tests

  • Controller spec (supertest): public GET, admin CSV/JSON, dryRun, 400s, 403 for non-admins.
  • Parser spec.
  • DB spec against postgres:13: only the address changes, unknown is reported, dry run writes nothing, list shape.

Unlike #272 (full replace of the abroad sections), this never creates or deletes sections.

GET /sections/abroad lists every abroad section with its town, country,
committee name (place) and street address, publicly, so the site no
longer needs a generated copy of the МВнР table.

PATCH /sections/abroad/addresses (Manage Section) and
npm run sections:update-abroad-addresses set the address of existing
32* sections from a CSV or JSON: only that column is written, unknown
ids are reported and never created, nothing is deleted, dryRun rolls
back. scripts/sections-preprocess/mfa_abroad_addresses.py turns the
МВнР xlsx into that CSV. See docs/abroad-addresses.md.
@hkdobrev
hkdobrev merged commit 8350e28 into main Oct 26, 2026
1 check passed
@hkdobrev
hkdobrev deleted the feature/abroad-sections-list-and-addresses branch October 26, 2026 07:52
hkdobrev added a commit to ti-broish/ti-broish that referenced this pull request Oct 26, 2026
The site reads abroad section addresses from GET /sections/abroad of the API (ti-broish/api#284) instead of the MFA table built into the code, so an address change no longer needs a deploy. The list is cached for 10 minutes (stale copy kept up to a day) and the last good copy is kept when the API fails. An API failure never blanks a Brevo address.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant