Commit 20c2e4f
Replace contest Q&A with threaded message system (#127)
* Replace simple Q&A with threaded message system for contest questions
Contest questions now support multi-message threads between contestants
and management instead of a single question/response pair. Each thread
has its own dedicated page with message history and reply form.
Backend: new contest_chat_messages table, GET/POST message endpoints,
author name resolution on responses, last_message_member_id for status
tracking. Existing questions migrated to chat messages in migration 53.
Frontend: member-side thread list with dedicated thread page,
management-side table with status/member columns and thread detail page.
Messages color-coded by role (contestant vs management).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address PR review feedback
- Fix "waiting" indicator to use last_message_member_id instead of
last_message_at (which is always set after migration)
- Copy arrays before sorting to avoid mutating react-query cache
- Use BigInt comparison for message sorting instead of Number() cast
- Batch member lookup with eqIn instead of N+1 selectOneFrom queries
- Derive contest from thread.contest_id instead of route param to
prevent wrong contest name in notifications
- Use getSnowflakeTime() in migration instead of hardcoded epoch
- Remove legacy PATCH endpoint (no old clients to support)
- Remove unused selfMemberId prop from ContestChatSection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address second round of PR review feedback
- Remove hardcoded snowflake bit-shift fallback in frontend sorting,
use BigInt comparison instead
- Use generateSnowflake() for response message IDs in migration
instead of question.id + 1n which risks primary key collision
- Allow admins (VIEW_CONTEST) to access GET messages endpoint without
being a contest member, mirroring the list endpoint behavior
- Allow admins (EDIT_CONTEST) to send messages via POST endpoint
without contest membership
- Add minLength: 1 to MessageSchema to prevent empty messages
- Convert users array to Map for O(1) lookups in name resolution
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address third round of PR review feedback
- Remove admin-without-membership path in POST messages — admins
must be contest members to send messages (management UI already
requires VIEW_PRIVATE membership). This avoids storing user.id
as author_member_id which breaks name resolution.
- Add fallback in name resolution: if author_member_id not found in
contest_members, try looking it up directly in users table.
- Drop showAllUsers: true from useAllContestMembers calls in
management pages to avoid query key cache collisions with other
pages using the same hook with default options.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* thing
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Antonio F. Trstenjak <antoniostignjedec@gmail.com>1 parent 41c07c4 commit 20c2e4f
18 files changed
Lines changed: 867 additions & 290 deletions
File tree
- apps
- backend/src
- database
- migrations
- routes/contest
- frontend/src
- hooks/contest/questions
- i18n/languages
- pages
- contests
- management/contest/questions
- routers
- packages/models/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
| 169 | + | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
| |||
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments