contests: exclude shadow-banned hosts from /v1/events/remix-contests#803
Merged
Conversation
The discovery list previously surfaced contests whose host was shadow-banned. v1EventComments already applies the two-signal shadow-ban filter (low_abuse_score + muted_by_karma) to comment authors; this mirrors the exact same pair against contest hosts. - Low-quality / impersonator / bot accounts → `aggregate_user.score < 0` (same `low_abuse_score` CTE used in v1_event_comments). - Community-flagged users → `muted_by_karma`, where the muters' combined follower_count crosses karmaCommentCountThreshold (same CTE shape, same threshold constant). Both CTEs are lifted verbatim from v1_event_comments.go so the contest-discovery and comment-author filters stay in lockstep. `get_events_by_ids`-style direct event lookups are unaffected — this filter only applies to the discovery list. Tests in TestRemixContestsExcludesShadowbannedHosts cover both signals: one host with score=-1 and one host muted by a follower-rich account. Both contests should disappear from the response while a clean host's contest is still returned. 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.
Summary
v1EventsRemixContests(api/v1_events_remix_contests.go) — the endpoint backing the contests discovery page on mobile + web — previously surfaced contests whose host was shadow-banned.v1EventCommentsalready applies the two-signal shadow-ban filter to comment authors; this PR mirrors the exact same pair against contest hosts so the discovery list and comment list stay in lockstep.This was originally drafted against `packages/discovery-provider/src/queries/get_events.py` in the apps monorepo (PR AudiusProject/apps#14297), but that Flask API was removed in #14236 and the file is dead code on main. Reopening here in the correct repo.
The two signals
aggregate_user.score < 0(low_abuse_scoreCTE)muted_by_karmaCTEfollower_countcrosseskarmaCommentCountThresholdBoth CTEs are lifted verbatim from
v1_event_comments.goso the filter is byte-for-byte identical to what the comment system applies to comment authors. Reuses the existingkarmaCommentCountThresholdconstant (defined at v1_track_comment_count.go:8).Implementation
Added two CTEs at the top of the SQL, two
NOT INfilters to the existingfiltersslice, and bound the threshold constant:u.is_deactivated = falseandu.is_available = truefilters stay in place. Shadow-ban filtering layers on top.e.entity_type != 'track' OR ...) is untouched.entry_countsLATERAL subquery are untouched.usersandtracksrelated lookups downstream are unaffected — they just see fewer rows.Tests
New
TestRemixContestsExcludesShadowbannedHoststest follows the exact pattern ofTestRemixContestsExcludesUnavailableContentalready in this file. Seeds three contests:Three sub-assertions: only the clean contest is returned; low-score contest absent; karma-muted contest absent.
`go build ./api/...` and `go vet ./api/...` both clean locally. Integration test couldn't be run end-to-end without a local Postgres at port 21300, but the test compiles fine and CI will run it against a fresh DB.
Test plan
go test ./api/.../v1/events/remix-contestson staging, confirm a known shadow-banned account's contest no longer appears in the responseuseAllRemixContestson mobile + web still returns the expected (non-shadowbanned) contests🤖 Generated with Claude Code