fix(trending-challenge-rewards): inline sol_reward_disbursements, drop dropped view#58
Merged
Conversation
…p dropped view The disburser's summary queries (getChallengesDisbursementsUserbanks and getChallengesDisbursementsUserbanksFriendly) left-joined the v_challenge_disbursements compatibility view, which the api repo dropped in migration 0212 (its routes were refactored to inline the join). Every /disburse run then threw `relation "v_challenge_disbursements" does not exist` (42P01) in the post-disbursement summary, so the Slack confirmation never posted -- even though payouts succeeded. Join sol_reward_disbursements directly on (challenge_id, specifier) for the slot. The table has one row per disbursement, so the slot resolution is unchanged; the prior view only added a recipient->user join that these queries never used (they already join users via user_challenges.user_id). Co-Authored-By: Claude Opus 4.7 <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
The trending disburser's summary queries (
getChallengesDisbursementsUserbanksandgetChallengesDisbursementsUserbanksFriendlyinqueries.ts)leftJointhev_challenge_disbursementscompatibility view. That view was dropped in api migration0212(the API routes were refactored to inline the join — seeapi/v1_challenges_disbursements.go). So every/disburserun now throws in the post-payout summary step:Payouts still succeed (they happen before the summary), but the exception fires before
chat.postMessage, so the Slack confirmation table never posts.Change
Join
sol_reward_disbursementsdirectly on(challenge_id, specifier)forslot, in both queries.sol_reward_disbursementshas exactly one row per(challenge_id, specifier), so the slot resolution is identical. The dropped view's only extra was arecipient_eth_address → usersjoin to resolveuser_id, which these queries never used — they already joinusersviauser_challenges.user_id.No other references to the view remain in the app.
Why this happened (context)
Surfaced while manually disbursing the corrected
2026-06-05trending/underground winners. All 23 rows paid out fine, but no Slack summary posted because of this 42P01. Recreating the view is a viable stopgap, but it resurrects something the api repo deliberately dropped — this decouples the disburser from it for good.Test plan
.leftJoin(table, joinFn)— structurally identical, type-unchanged (full monorepo typecheck not run here due to local dep skew; no errors referencequeries.ts)./disburse <date>, the summary query runs and the Slack table posts (no 42P01).🤖 Generated with Claude Code