chore(discovery-provider): remove dead query helpers + tests (Option B / deferred from #14298)#14299
Draft
dylanjeffers wants to merge 1 commit into
Draft
chore(discovery-provider): remove dead query helpers + tests (Option B / deferred from #14298)#14299dylanjeffers wants to merge 1 commit into
dylanjeffers wants to merge 1 commit into
Conversation
…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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
Unit tests in src/queries/ (2)
Integration tests (49)
How dead-ness was verified
For each
src/queries/*.py, counted callers excluding the file itself, all unit/integration test files:Files with
live_refs=0and 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.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— exercisessrc.challenges.challenge_event_bus,src.challenges.challengetest_get_challenges.py— exercisessrc.challenges.listen_streak_endless_challenge,src.challenges.referral_challengetest_undisbursed_challenges.py— exercises challenges + disbursement modelstest_get_attestation.py— exercisessrc.tasks.index_oraclestest_get_plays_metrics.py— exercisessrc.tasks.index_hourly_play_countstest_get_top_genre_users.py— exercisessrc.tasks.update_aggregatestest_get_user_listening_history.py— exercisessrc.tasks.user_listening_history.index_user_listening_historyintegration_tests/queries/test_notifications/test_*.pyfiles + 5integration_tests/tasks/test_*_remix_contest_*.pyfiles — each runs a live notification-creation task (insrc.tasks.remix_contest_notifications.*etc.), then asserts viaget_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
src/queries/get_extended_purchase_gate.py— only test caller is its own integration test, butsrc/tasks/index_payment_router.pyalso imports it. Live, kept.get_block_confirmationandget_latest_playpairs — already removed in chore(discovery-provider): remove dead Python files orphaned by Flask removal #14298.src/tasks/,src/eth_indexing/,src/solana/,src/challenges/.Verification
python3 -m compileall -q packages/discovery-provider/src packages/discovery-provider/integration_tests→ exit 0rgfor every removed module name acrosspackages/discovery-provider/→ no remaining import referencesnpm run protocol) and confirm celery beat + workers come up cleanly🤖 Generated with Claude Code