fix(scrapers): disambiguate EMISS yearly vs Q1 in dedup key (#1606) #1687

Merged
lekss361 merged 1 commit from fix/emiss-period-dedup-1606 into main 2026-06-17 17:55:27 +00:00
Owner

Проблема (#1606)

rosstat_emiss.py: _emiss_period_to_month маппил и «год», и «I квартал» в month=1 → dedup-ключ (region, obs_date) коллидировал, годовой и Q1 перетирали друг друга.

Решение

_emiss_period_granularity() (year/quarter/month) добавлен в in-memory ключ → 3-tuple (region, obs_date, granularity). Оба ряда выживают парсинг. DB-level PK (indicator_type, region, obs_date) — pre-existing ограничение схемы, не трогается.

Verify

ruff clean; pytest (emiss/rosstat) → 49 passed, 1 skipped (+2 теста).

Closes #1606

## Проблема (#1606) `rosstat_emiss.py`: `_emiss_period_to_month` маппил и «год», и «I квартал» в month=1 → dedup-ключ `(region, obs_date)` коллидировал, годовой и Q1 перетирали друг друга. ## Решение `_emiss_period_granularity()` (year/quarter/month) добавлен в in-memory ключ → 3-tuple `(region, obs_date, granularity)`. Оба ряда выживают парсинг. DB-level PK `(indicator_type, region, obs_date)` — pre-existing ограничение схемы, не трогается. ## Verify `ruff` clean; `pytest` (emiss/rosstat) → **49 passed, 1 skipped** (+2 теста). Closes #1606
lekss361 added 1 commit 2026-06-17 17:45:58 +00:00
fix(scrapers): disambiguate EMISS yearly vs Q1 in dedup key (#1606)
Some checks failed
CI / changes (push) Successful in 7s
CI / changes (pull_request) Successful in 7s
CI / backend-tests (push) Has been skipped
CI / frontend-tests (push) Has been skipped
CI / openapi-codegen-check (push) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 1m38s
CI / backend-tests (pull_request) Failing after 8m41s
9dbfb03a3d
_YEAR_PERIODS ('год') → month=1 collided with Q1 ('I квартал') → month=1
for the same region/year: both produced obs_date=YYYY-01-01, so the second
series in the XML silently overwrote the first in the in-memory by_key dict.

Fix: add _emiss_period_granularity() and extend the dedup key from
(region, obs_date) to (region, obs_date, granularity). 'year' and 'quarter'
are now distinct slots, so both rows survive the parser and reach the upsert.

Test: test_yearly_and_q1_both_survive_dedup verifies len==2 with both
values present; test_period_granularity covers all classification branches.
lekss361 merged commit 435f7249d0 into main 2026-06-17 17:55:27 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1687
No description provided.