Skip to content

feat: community have/want enrichment for release rarity scoring#293

Merged
SimplicityGuy merged 12 commits intomainfrom
feat/206-community-rarity-enrichment
Apr 11, 2026
Merged

feat: community have/want enrichment for release rarity scoring#293
SimplicityGuy merged 12 commits intomainfrom
feat/206-community-rarity-enrichment

Conversation

@SimplicityGuy
Copy link
Copy Markdown
Owner

Summary

Closes #206

  • Add 6th "collection prevalence" rarity signal (weight 0.20) that scores releases inversely to Discogs community ownership counts
  • Add enrichment endpoint (GET /api/internal/insights/community-enrichment) that fetches community.have/community.want from the Discogs REST API for releases in user collections/wantlists
  • Store community counts in PostgreSQL (insights.community_counts) and mirror to Neo4j Release node properties
  • Integrate into rarity scoring pipeline with 7-day staleness refresh, OAuth 1.0a auth, and 60 req/min rate limiting with retry

Changes

  • Schema: New insights.community_counts table, collection_prevalence column on insights.release_rarity
  • Scoring: compute_collection_prevalence_score() with log-scale thresholds (0→95, 10k+→10) and want-pressure bonus
  • Weights: Redistributed to accommodate 6th signal — pressing 0.25, temporal 0.20, prevalence 0.20, isolation 0.15, label 0.10, format 0.10
  • Pipeline: Enrichment runs before rarity computation in insights scheduler
  • Tests: 19 scoring tests, 3 enrichment tests, updated integration tests (3078 total pass)

Test plan

  • All 3078 tests pass
  • mypy clean, ruff clean
  • Scoring function covers all threshold boundaries and edge cases
  • Enrichment handles: no releases, no credentials, successful fetch, rate limiting with retry
  • Neutral fallback (50.0) for unenriched releases preserves existing scores

🤖 Generated with Claude Code

SimplicityGuy and others added 11 commits April 11, 2026 15:45
Design for fetching Discogs community.have/want counts via REST API
to add a 6th "collection prevalence" rarity signal (weight 0.20).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8-task plan covering schema, scoring function, signal integration,
enrichment endpoint, and pipeline updates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eights (#206)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#206)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…evalence (#206)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nce (#206)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add compute_and_store_community_enrichment function and wire it into
run_all_computations before release_rarity so community counts are
fresh when rarity scores are computed. Update tests to cover 7 insight
types and fix mock tuple width for collection_prevalence column.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix INTERVAL parameterization using make_interval() instead of string
  interpolation inside SQL literal
- Fix 429 retry logic: use inner while loop so rate-limited releases are
  retried instead of silently skipped
- Update module docstring from 5-signal to 6-signal
- Add exc_info=True to community counts loading warning for debuggability

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 94.36620% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
api/routers/insights_compute.py 93.75% 6 Missing ⚠️
insights/computations.py 88.23% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (chromium)

Totals Coverage
Statements: 44.5% ( 1251 / 2811 )
Lines: 44.5% ( 1251 / 2811 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit)

Totals Coverage
Statements: 44.5% ( 1251 / 2811 )
Lines: 44.5% ( 1251 / 2811 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (firefox)

Totals Coverage
Statements: 44.5% ( 1251 / 2811 )
Lines: 44.5% ( 1251 / 2811 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPad Pro 11)

Totals Coverage
Statements: 44.5% ( 1251 / 2811 )
Lines: 44.5% ( 1251 / 2811 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPhone 15)

Totals Coverage
Statements: 44.5% ( 1251 / 2811 )
Lines: 44.5% ( 1251 / 2811 )

StandWithUkraine

@SimplicityGuy SimplicityGuy merged commit 0b5aac4 into main Apr 11, 2026
57 checks passed
@SimplicityGuy SimplicityGuy deleted the feat/206-community-rarity-enrichment branch April 11, 2026 23:45
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.

feat: Community have/want count enrichment for release rarity scoring

1 participant