feat(11-02): normalizer derives bundesland + backfill migration for existing rows
Replace the Phase-10-deferred `bundesland = null` assignment with bundeslandFromRegion(region) so new ingests are Bundesland-filterable immediately. Add @@index([bundesland]) for filter performance. New handwritten migration 20260721140000_tender_bundesland_backfill backfills the ~1671 pre-existing rows (idempotent UPDATE, only where bundesland IS NULL AND region IS NOT NULL) — applied locally via `docker exec tessera-ctl-db-1 psql`, resolved as applied in _prisma_migrations, and prisma generate re-run. Verified on the local dev DB: 933/1671 rows now have bundesland set across all 16 Länder (738 remain NULL where region itself is NULL). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { createHash } from 'crypto';
|
||||
import { bundeslandFromRegion } from './geo/nuts-bundesland';
|
||||
import type { NormalizedTenderFields, RawTenderRecord } from './tender.types';
|
||||
|
||||
/**
|
||||
@@ -33,9 +34,11 @@ export class TenderNormalizerService {
|
||||
const cpvCodes = extractCpvCodes(ocdsTender);
|
||||
const region = textValue(ocdsBuyer?.address?.region);
|
||||
const plz = textValue(ocdsBuyer?.address?.postalCode);
|
||||
// NUTS->Bundesland name mapping deferred to Phase 11 (filter UI) — not
|
||||
// required for this phase's ingestion core.
|
||||
const bundesland: string | null = null;
|
||||
// Phase 11 (FILTER-02, Pitfall 1): derive bundesland from region's
|
||||
// NUTS-1 prefix so new ingests are filterable immediately — the
|
||||
// ~1671 pre-existing rows are backfilled by a one-time migration
|
||||
// (20260721140000_tender_bundesland_backfill).
|
||||
const bundesland = bundeslandFromRegion(region);
|
||||
|
||||
const deadlineAt =
|
||||
extractEformsDeadline(eformsRoot) ??
|
||||
|
||||
Reference in New Issue
Block a user