Repository navigation
D572 part 3b (#1183): payout destination (Q1 = A) and the leaderboard by metric, period and change (migration 409) - #1324
Merged
Conversation
…eriod and change - Migration 409: payouts.destination_label / destination_last4, and partner_leaderboard_snapshots written daily by the cron at 05:25 UTC. - POST /network/payouts takes an optional destination (label and last 4, both or neither) and refuses a bad one before any commission is claimed. - GET /partnernet/leaderboard/board ranks by score, referrals or commissions (counts, never sums), all time or this quarter, with the change against a standing at least 7 days old, or the reason there is none. - Partner earnings form, history and admin queue show where a payout is sent; the leaderboard page gains metric and period chips and a change column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8iwbvTs6nntzGe7MxmvUm
|
Preview: https://studioos-pr-1324.guillaumelauzier.workers.dev (built from aeb7b56) The pull request's SPA build on a Worker with no bindings: pages and deep links work, |
guillaumelauzier
marked this pull request as ready for review
October 6, 2026 23:19
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.
Objective
Part 3b of D572. It does two things:
Closes #1183
Implementation
payouts.destination_labelandpayouts.destination_last4. Adds thepartner_leaderboard_snapshotstable (primary key: date, metric, period key, user), with an index for lookups.POST /network/payoutstakes an optional destination.destination_incomplete,invalid_destination_label,invalid_destination_last4) before any commission is claimed.CREATE TABLE payoutsgains both columns, to keep schema-pair parity.services/partnerLeaderboard.ts(new) ranks three metrics:INSERT OR IGNORE(idempotent). Each board is written on its own, so one failure costs only that board's rows.GET /partnernet/leaderboard/board?metric&periodreturns the top 25 rows.is_viewer. No id, name or email is sent for any other member.compareandtotal_ranked.bad_metric,bad_period,period_not_for_metric, and 503board_unreadable.'1970-01-01 00:00:00', not0000-…, because SQLite'sdatetime()reads the latter as NULL. This is noted in D572.Files changed
cloudflare-worker/sql/migrations/409_payout_destination_and_leaderboard.sql: new columns and the snapshot table.cloudflare-worker/src/services/partnerLeaderboard.ts: ranking, snapshots, comparison.cloudflare-worker/src/routes/partnernet.ts:GET /leaderboard/board.cloudflare-worker/src/routes/network.ts:readPayoutDestination, the insert, and the runtime CREATE.cloudflare-worker/src/index.ts: the snapshot cron.frontend/src/lib/api.js:partnerLeaderboardBoardreplacespartnerLeaderboard.frontend/src/lib/partnerEarnings.js: destination helpers, board metrics and periods,changeText.frontend/src/pages/partner/earnings/PartnerEarnings.jsx,PartnerLeaderboard.jsx,frontend/src/pages/admin/AdminCommissions.jsx: the UI changes above.documentation/architecture/decisions/D572.md: the Part 3b section.cloudflare-worker/test/partner_earnings_3b_d572.test.ts(new),frontend/test/partner_leaderboard_d572.test.mjs(new), and updates topartner_earnings_d569.test.mjsandpartner_earnings_d572.test.ts.Testing
npm run build: exit 0.npm run test:drift > drift.log 2>&1; echo EXIT=$?: EXIT=0.docs/is not committed.Risks
dangerouslySetInnerHTML. Auth gates are unchanged; the board route sits behind the existing partnernet auth. Other members appear only as rank and role. Only the last 4 characters of a destination are stored.Dependencies
Agent
S09 · Claude Code
Review requested
S1
🤖 Generated with Claude Code
https://claude.ai/code/session_01L8iwbvTs6nntzGe7MxmvUm
Generated by Claude Code