Skip to content

Commit 6ecdad4

Browse files
0xdevcollinsclaude
andauthored
fix(rewards): match track winners by submissionId, not participantId (#582)
The publish-wizard preview was still showing "3 of 8 winners assigned" even after the track-winner enrichment landed in #576. The enrichment effect was looking up trackWinners by `sub.id`, but the rewards data mapper sets `Submission.id` to the participant ID, not the submission row ID. The Map lookup keyed by `HackathonTrackWinner.submissionId` never matched, so no submissions got `isTrackWinner = true` stamped. For the Boundless × Trustless Work hackathon (3 overall + 5 track winners), the wizard saw only the 3 overall winners — the 5 track winners never made it into the `winners` array. Fix: - Add `submissionId?: string` to the `Submission` type. - Mapper populates it from `submissionData.id || sub.id || sub.submissionId`. The mapper's `id` field stays on the participant ID for compatibility with the existing rank-assignment code that already keys off it. - Track-winner enrichment looks up `byId.get(sub.submissionId)` first, falls back to `byId.get(sub.id)` for older rows where the mapper output predated the new field. After this, the wizard will show "All 8 winners assigned • 1,500 USDC pool" with the three overall placements and five track winners. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e32eae4 commit 6ecdad4

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

components/organization/hackathons/rewards/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
export interface Submission {
22
id: string;
3+
/**
4+
* The actual HackathonSubmission row ID, distinct from `id` which the
5+
* rewards data mapper sets to the participant ID. Required for
6+
* matching submissions against backend payloads (judging results,
7+
* track winners) that key by submissionId.
8+
*/
9+
submissionId?: string;
310
name: string;
411
projectName: string;
512
avatar?: string;

hooks/use-hackathon-rewards.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,14 @@ export const useHackathonRewards = (
472472
const byId = new Map(fetched.map(tw => [tw.submissionId, tw]));
473473
setSubmissions(prev =>
474474
prev.map(sub => {
475-
const tw = byId.get(sub.id);
475+
// Match against the real submission row ID (now threaded
476+
// through by the mapper). Fall back to `sub.id` for any
477+
// mapper output that predates the `submissionId` field —
478+
// older rows would have `id === submissionId` when
479+
// participant data was missing.
480+
const tw =
481+
(sub.submissionId && byId.get(sub.submissionId)) ||
482+
byId.get(sub.id);
476483
if (!tw) return sub;
477484
return {
478485
...sub,

lib/utils/rewards-data-mapper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export const mapJudgingSubmissionToRewardSubmission = (
6363

6464
return {
6565
id: participant.id || sub.id || '',
66+
// The real submission row ID, used by backend payloads (judging
67+
// results, track winners) that key by submissionId. The mapper's
68+
// `id` field stays on the participant ID for compatibility with
69+
// existing rank-assignment and display code that already keys off
70+
// it.
71+
submissionId: submissionData.id || sub.id || sub.submissionId || '',
6672
participantId: participant.id || sub.id || '',
6773
name,
6874
projectName: submissionData.projectName || '',

0 commit comments

Comments
 (0)