Skip to content

chore(discovery-provider): remove dead query helpers + tests (Option B / deferred from #14298)#14299

Draft
dylanjeffers wants to merge 1 commit into
mainfrom
dylan/discovery-provider-dead-code-deferred
Draft

chore(discovery-provider): remove dead query helpers + tests (Option B / deferred from #14298)#14299
dylanjeffers wants to merge 1 commit into
mainfrom
dylan/discovery-provider-dead-code-deferred

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

DRAFT — listing every deletion so reviewers can spot-check before merge.

Summary

Follow-up to #14298. That PR removed query files with zero callers anywhere in the repo. This one tackles the deferred set: 31 query helpers whose only callers are tests that exist to verify them. Production code paths are unreached after the Flask removal in #14236; the tests were testing dead code (or, in some cases, using a dead query as a verification tool for a still-live indexer task — see "Risk" below).

82 files / ~14k lines deleted.

Files deleted

Production query helpers (31)

src/queries/get_aggregate_route_metrics.py
src/queries/get_app_name_metrics.py
src/queries/get_attestation.py
src/queries/get_challenges.py
src/queries/get_collection_library.py
src/queries/get_follow_intersection_users.py
src/queries/get_genre_metrics.py
src/queries/get_historical_route_metrics.py
src/queries/get_notifications.py
src/queries/get_personal_route_metrics.py
src/queries/get_plays_metrics.py
src/queries/get_prev_track_entries.py
src/queries/get_related_artists.py
src/queries/get_remixable_tracks.py
src/queries/get_remixes_of.py
src/queries/get_repost_feed_for_user.py
src/queries/get_tips.py
src/queries/get_top_genre_users.py
src/queries/get_top_listeners_for_track.py
src/queries/get_top_user_track_tags.py
src/queries/get_top_users.py
src/queries/get_total_plays.py
src/queries/get_trailing_metrics.py
src/queries/get_undisbursed_challenges.py
src/queries/get_usdc_purchases.py
src/queries/get_usdc_transactions_history.py
src/queries/get_user_listen_counts_monthly.py
src/queries/get_user_listening_history.py
src/queries/get_user_playlist_update.py
src/queries/get_user_signals.py
src/queries/get_users_account.py

Unit tests in src/queries/ (2)

src/queries/get_genre_metrics_unit_test.py
src/queries/get_plays_metrics_unit_test.py

Integration tests (49)

integration_tests/challenges/test_challenges.py
integration_tests/queries/test_get_aggregate_app_metrics.py
integration_tests/queries/test_get_aggregate_route_metrics.py
integration_tests/queries/test_get_aggregate_route_metrics_trailing_month.py
integration_tests/queries/test_get_attestation.py
integration_tests/queries/test_get_challenges.py
integration_tests/queries/test_get_collections_library.py
integration_tests/queries/test_get_genre_metrics.py
integration_tests/queries/test_get_historical_app_metrics.py
integration_tests/queries/test_get_historical_route_metrics.py
integration_tests/queries/test_get_personal_route_metrics.py
integration_tests/queries/test_get_plays_metrics.py
integration_tests/queries/test_get_prev_track_entries.py
integration_tests/queries/test_get_related_artists.py
integration_tests/queries/test_get_repost_feed_for_user.py
integration_tests/queries/test_get_tips.py
integration_tests/queries/test_get_top_genre_users.py
integration_tests/queries/test_get_top_user_track_tags.py
integration_tests/queries/test_get_total_plays.py
integration_tests/queries/test_get_tracks.py
integration_tests/queries/test_get_usdc_purchases.py
integration_tests/queries/test_get_usdc_transactions_history.py
integration_tests/queries/test_get_user_listen_counts_monthly.py
integration_tests/queries/test_get_user_listening_history.py
integration_tests/queries/test_get_user_signals.py
integration_tests/queries/test_get_users_account.py
integration_tests/queries/test_mutual_follows.py
integration_tests/queries/test_notifications/test_announcement_notification.py
integration_tests/queries/test_notifications/test_follow_notification.py
integration_tests/queries/test_notifications/test_get_unread_notification_count.py
integration_tests/queries/test_notifications/test_paginate_notification.py
integration_tests/queries/test_notifications/test_remix_track_notification.py
integration_tests/queries/test_notifications/test_repost_notification.py
integration_tests/queries/test_notifications/test_repost_repost_notifications.py
integration_tests/queries/test_notifications/test_save_notification.py
integration_tests/queries/test_notifications/test_save_of_repost_notification.py
integration_tests/queries/test_notifications/test_tastemaker_notification.py
integration_tests/queries/test_notifications/test_track_added_to_playlist_notification.py
integration_tests/queries/test_notifications/test_trending_playlist_notification.py
integration_tests/queries/test_notifications/test_trending_underground_notification.py
integration_tests/queries/test_notifications/test_user_tier_change_notification.py
integration_tests/queries/test_populate_user_metadata.py
integration_tests/queries/test_undisbursed_challenges.py
integration_tests/queries/test_user_playlist_update.py
integration_tests/tasks/test_artist_remix_contest_ending_soon_notification.py
integration_tests/tasks/test_artist_remix_contest_submissions_notification.py
integration_tests/tasks/test_fan_remix_contest_ended_notification.py
integration_tests/tasks/test_fan_remix_contest_ending_soon_notification.py
integration_tests/tasks/test_fan_remix_contest_started_notification.py

How dead-ness was verified

For each src/queries/*.py, counted callers excluding the file itself, all unit/integration test files:

for f in packages/discovery-provider/src/queries/*.py; do
  base=$(basename "$f" .py)
  live_refs=$(rg -l "\b$base\b" packages/discovery-provider --type py \
    | grep -v "^$f$" | grep -v "_unit_test\.py$" \
    | grep -v "/test_.*\.py$" | grep -v "/integration_tests/" \
    | wc -l)
  [ "$live_refs" = "0" ] && echo "$base"
done

Files with live_refs=0 and total refs > 0 (only tests reach them) are in this PR. Each integration test was checked back against the dead set — no test deleted here imports any surviving production module.

⚠️ Risk: tests that incidentally exercise live indexer code

These ~20 tests use a dead query as their assertion tool but exercise still-live indexer / task code in the setup phase. Deleting them means losing integration coverage for the live module. Please OK each (or restore the test + keep the dead query, or refactor to query the DB directly):

  • test_challenges.py — exercises src.challenges.challenge_event_bus, src.challenges.challenge
  • test_get_challenges.py — exercises src.challenges.listen_streak_endless_challenge, src.challenges.referral_challenge
  • test_undisbursed_challenges.py — exercises challenges + disbursement models
  • test_get_attestation.py — exercises src.tasks.index_oracles
  • test_get_plays_metrics.py — exercises src.tasks.index_hourly_play_counts
  • test_get_top_genre_users.py — exercises src.tasks.update_aggregates
  • test_get_user_listening_history.py — exercises src.tasks.user_listening_history.index_user_listening_history
  • The 14 integration_tests/queries/test_notifications/test_*.py files + 5 integration_tests/tasks/test_*_remix_contest_*.py files — each runs a live notification-creation task (in src.tasks.remix_contest_notifications.* etc.), then asserts via get_notifications.

The remaining ~25 tests are pure black-box assertions of the dead query helper alone (e.g. test_get_tips.py, test_get_repost_feed_for_user.py) — no live coverage is lost there.

What was intentionally NOT touched

Verification

  • python3 -m compileall -q packages/discovery-provider/src packages/discovery-provider/integration_tests → exit 0
  • Post-deletion rg for every removed module name across packages/discovery-provider/ → no remaining import references
  • CI green
  • Boot the protocol stack (npm run protocol) and confirm celery beat + workers come up cleanly
  • Surviving discovery-provider test suite passes

🤖 Generated with Claude Code

…ption B)

Follow-up to #14298. That PR removed query files with literally zero
callers in the repo. This one tackles the deferred set: query helpers
whose only callers are tests that exist to verify them. The production
code paths are unreached after the Flask removal in #14236; the tests
were testing dead code (or, in some cases, were using a dead query as
a verification tool for a still-live indexer task — see the risk
section below).

## Scope

82 files / ~14k lines deleted.

### Production query helpers (31)

src/queries/get_aggregate_route_metrics.py
src/queries/get_app_name_metrics.py
src/queries/get_attestation.py
src/queries/get_challenges.py
src/queries/get_collection_library.py
src/queries/get_follow_intersection_users.py
src/queries/get_genre_metrics.py
src/queries/get_historical_route_metrics.py
src/queries/get_notifications.py
src/queries/get_personal_route_metrics.py
src/queries/get_plays_metrics.py
src/queries/get_prev_track_entries.py
src/queries/get_related_artists.py
src/queries/get_remixable_tracks.py
src/queries/get_remixes_of.py
src/queries/get_repost_feed_for_user.py
src/queries/get_tips.py
src/queries/get_top_genre_users.py
src/queries/get_top_listeners_for_track.py
src/queries/get_top_user_track_tags.py
src/queries/get_top_users.py
src/queries/get_total_plays.py
src/queries/get_trailing_metrics.py
src/queries/get_undisbursed_challenges.py
src/queries/get_usdc_purchases.py
src/queries/get_usdc_transactions_history.py
src/queries/get_user_listen_counts_monthly.py
src/queries/get_user_listening_history.py
src/queries/get_user_playlist_update.py
src/queries/get_user_signals.py
src/queries/get_users_account.py

### Unit tests in src/queries/ (2)

src/queries/get_genre_metrics_unit_test.py
src/queries/get_plays_metrics_unit_test.py

### Integration tests (49)

integration_tests/challenges/test_challenges.py
integration_tests/queries/test_get_aggregate_app_metrics.py
integration_tests/queries/test_get_aggregate_route_metrics.py
integration_tests/queries/test_get_aggregate_route_metrics_trailing_month.py
integration_tests/queries/test_get_attestation.py
integration_tests/queries/test_get_challenges.py
integration_tests/queries/test_get_collections_library.py
integration_tests/queries/test_get_genre_metrics.py
integration_tests/queries/test_get_historical_app_metrics.py
integration_tests/queries/test_get_historical_route_metrics.py
integration_tests/queries/test_get_personal_route_metrics.py
integration_tests/queries/test_get_plays_metrics.py
integration_tests/queries/test_get_prev_track_entries.py
integration_tests/queries/test_get_related_artists.py
integration_tests/queries/test_get_repost_feed_for_user.py
integration_tests/queries/test_get_tips.py
integration_tests/queries/test_get_top_genre_users.py
integration_tests/queries/test_get_top_user_track_tags.py
integration_tests/queries/test_get_total_plays.py
integration_tests/queries/test_get_tracks.py
integration_tests/queries/test_get_usdc_purchases.py
integration_tests/queries/test_get_usdc_transactions_history.py
integration_tests/queries/test_get_user_listen_counts_monthly.py
integration_tests/queries/test_get_user_listening_history.py
integration_tests/queries/test_get_user_signals.py
integration_tests/queries/test_get_users_account.py
integration_tests/queries/test_mutual_follows.py
integration_tests/queries/test_notifications/test_announcement_notification.py
integration_tests/queries/test_notifications/test_follow_notification.py
integration_tests/queries/test_notifications/test_get_unread_notification_count.py
integration_tests/queries/test_notifications/test_paginate_notification.py
integration_tests/queries/test_notifications/test_remix_track_notification.py
integration_tests/queries/test_notifications/test_repost_notification.py
integration_tests/queries/test_notifications/test_repost_repost_notifications.py
integration_tests/queries/test_notifications/test_save_notification.py
integration_tests/queries/test_notifications/test_save_of_repost_notification.py
integration_tests/queries/test_notifications/test_tastemaker_notification.py
integration_tests/queries/test_notifications/test_track_added_to_playlist_notification.py
integration_tests/queries/test_notifications/test_trending_playlist_notification.py
integration_tests/queries/test_notifications/test_trending_underground_notification.py
integration_tests/queries/test_notifications/test_user_tier_change_notification.py
integration_tests/queries/test_populate_user_metadata.py
integration_tests/queries/test_undisbursed_challenges.py
integration_tests/queries/test_user_playlist_update.py
integration_tests/tasks/test_artist_remix_contest_ending_soon_notification.py
integration_tests/tasks/test_artist_remix_contest_submissions_notification.py
integration_tests/tasks/test_fan_remix_contest_ended_notification.py
integration_tests/tasks/test_fan_remix_contest_ending_soon_notification.py
integration_tests/tasks/test_fan_remix_contest_started_notification.py

## How this set was identified

For each `src/queries/*.py`, counted callers under `packages/discovery-provider/`
excluding the file itself and excluding test files (`*_unit_test.py`,
`/test_*.py`, anything under `integration_tests/`):

```bash
for f in packages/discovery-provider/src/queries/*.py; do
  base=$(basename "$f" .py)
  live_refs=$(rg -l "\b$base\b" packages/discovery-provider --type py \
    | grep -v "^$f$" | grep -v "_unit_test\.py$" \
    | grep -v "/test_.*\.py$" | grep -v "/integration_tests/" \
    | wc -l)
  [ "$live_refs" = "0" ] && echo "$base"
done
```

Files with 0 live refs but >0 total refs (i.e., only tests reach them)
landed in this PR. Each test was paired back to the prod module(s) it
imports. Tests that exclusively import from the dead set are included
in the deletion; no test is being deleted that imports any surviving
production module.

## Risk: tests that incidentally exercise live indexer code

A handful of the integration tests use a dead query as their *assertion
tool* but exercise still-live indexer / task code in the setup phase.
Deleting them loses integration coverage for the underlying live module.
Reviewer should explicitly OK each of these or restore the test (and
either keep the dead query or refactor the test to query the DB
directly):

- `integration_tests/challenges/test_challenges.py` — exercises
  `src.challenges.challenge_event_bus`, `src.challenges.challenge`
  (live). Asserts via `get_challenges`.
- `integration_tests/queries/test_get_challenges.py` — exercises
  `src.challenges.listen_streak_endless_challenge`,
  `src.challenges.referral_challenge` (live). Asserts via
  `get_challenges`.
- `integration_tests/queries/test_undisbursed_challenges.py` — uses
  the challenges/disbursement models (live). Asserts via
  `get_undisbursed_challenges`.
- `integration_tests/queries/test_get_attestation.py` — exercises
  `src.tasks.index_oracles` (live). Asserts via `get_attestation`.
- `integration_tests/queries/test_get_plays_metrics.py` — exercises
  `src.tasks.index_hourly_play_counts._index_hourly_play_counts`
  (live). Asserts via `get_plays_metrics`.
- `integration_tests/queries/test_get_top_genre_users.py` — exercises
  `src.tasks.update_aggregates._update_aggregates` (live). Asserts via
  `get_top_genre_users`.
- `integration_tests/queries/test_get_user_listening_history.py` —
  exercises `src.tasks.user_listening_history.index_user_listening_history`
  (live). Asserts via `get_user_listening_history` +
  `get_top_listeners_for_track`.
- The 14 `integration_tests/queries/test_notifications/test_*` files +
  the 5 `integration_tests/tasks/test_*_remix_contest_*` files —
  each runs a notification-creation task (live, in
  `src.tasks.remix_contest_notifications.*` etc.), then asserts via
  `get_notifications`.

The other ~25 tests in the deletion set are pure black-box assertions
of the dead query helper alone (e.g. `test_get_tips.py`,
`test_get_repost_feed_for_user.py`) — no live coverage is lost there.

## Verification

- `python3 -m compileall -q packages/discovery-provider/src
  packages/discovery-provider/integration_tests` → exit 0
- Post-deletion `rg` for every removed module name across
  `packages/discovery-provider/` found no remaining import references.

## What was intentionally NOT touched

- `src/queries/get_extended_purchase_gate.py` — only test caller is
  `test_get_extended_purchase_gate.py`, but `src/tasks/index_payment_router.py`
  also imports it. Live.
- `src/queries/get_block_confirmation_unit_test.py` and
  `src/queries/get_latest_play_unit_test.py` and their prod pairs —
  already in #14298.
- All indexing code under `src/tasks/`, `src/eth_indexing/`,
  `src/solana/`, `src/challenges/`. None flagged as dead.

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

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: e78bc3b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant