Skip to content

feat: add country column and US-preferred dedup ranking#8

Merged
jakebromberg merged 1 commit intomainfrom
feat/country-dedup
Feb 19, 2026
Merged

feat: add country column and US-preferred dedup ranking#8
jakebromberg merged 1 commit intomainfrom
feat/country-dedup

Conversation

@jakebromberg
Copy link
Member

Summary

  • Add country text column to the release table schema (permanent, kept for consumers)
  • Change dedup ranking from "most tracks, then lowest ID" to "US first, then most tracks, then lowest ID" via (r.country = 'US')::int DESC
  • Include country in dedup copy-swap SELECT list, import mapping, and copy-to-target spec
  • Restructure test fixtures so country preference is the decisive factor in dedup group 500 (US/3 tracks beats UK/5 tracks), while group 600 tests fallback behavior (no US release, track count decides)

Closes #7

Test plan

  • Unit tests pass (212 tests)
  • Integration tests pass (107 tests) — pytest -m postgres
  • E2E tests pass (22 tests) — pytest -m e2e
  • Ruff linting passes
  • test_us_preferred_over_track_count proves country is decisive (kept release has fewer tracks than removed one)
  • test_country_column_preserved verifies country survives dedup copy-swap
  • test_country_column_present (E2E) verifies column in final schema

As a US radio station, prefer US pressings when deduplicating releases
by master_id. The dedup ranking changes from "most tracks, then lowest
ID" to "US first, then most tracks, then lowest ID".

- Add `country text` column to release table schema
- Add country to CSV-to-DB import column mapping
- Change dedup ORDER BY to `(r.country = 'US')::int DESC` first
- Include country in dedup copy-swap SELECT list (permanent column)
- Add country to COPY_TABLE_SPEC for copy-to-target mode
- Restructure test fixtures so country preference is decisive:
  master_id 500: US/3 tracks beats UK/5 tracks (country wins)
  master_id 600: DE/4 tracks beats UK/2 tracks (fallback to track count)
@jakebromberg jakebromberg merged commit ecfb82b into main Feb 19, 2026
3 checks passed
@jakebromberg jakebromberg deleted the feat/country-dedup branch February 19, 2026 19:44
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.

Add country column and US-preferred dedup ranking

1 participant

Comments