Skip to content

Keep the abroad section addresses in the API - #283

Closed
hkdobrev wants to merge 1 commit into
feature/abroad-section-addressesfrom
feature/abroad-addresses-endpoints
Closed

hkdobrev wants to merge 1 commit into
feature/abroad-section-addressesfrom
feature/abroad-addresses-endpoints

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).

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 deleted the branch feature/abroad-section-addresses October 26, 2026 07:49
@hkdobrev hkdobrev closed this Oct 26, 2026
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