Repository navigation
feat(mod): recorderFriendCode w payloadzie v2 (schemaVersion 3.0.0) i w D1 - #383
Merged
Merged
Conversation
… in D1 The v2 payload now has schemaVersion 3.0.0 and a required recorderFriendCode: the friend code of the machine that recorded the match. A missing field, null, or a 2.0.0 payload gives 400. The endpoint stays /api/v2/games. Migration 0013 adds games.recorderFriendCode and games.recorderPlayerId (relation to players, ON DELETE SET NULL). It is hand-written with ALTER TABLE ADD COLUMN, because the Prisma diff rebuilds the games table. createGameV2 takes the id of the payload player with the same friend code, else the one live player with that code, else NULL. The upload never fails on this. Both columns stay in D1. getGameData and the POST response do not show them. Tests: gamesV2 (missing, null, 2.0.0), recorder.ts (three cases), getGameData. HostClient.tsx sends the file text as it is, so a 3.0.0 file works there with no change. Refs #377 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quarties
commented
Oct 21, 2026
quarties
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review
Kod jest gotowy do merge. Brak blokerów. Merge tylko w oknie przełączenia, razem z hostem 1.2.0.
| Punkt | Wynik |
|---|---|
gamesV2.ts: z.literal('3.0.0'), recorderFriendCode: z.string().min(1), .strict() |
OK. Brak pola, null, '' i 2.0.0 dają 400 |
Migracja 0013 |
OK. main ma już 0012. Migracje 0001–0013 przechodzą w sqlite3. FK players.id, ON DELETE SET NULL. prisma migrate diff do schema.prisma daje pustą migrację |
Reguła recorderPlayerId |
OK. Krok (a) z dbIdByPlayerId, krok (b) findMany z deletedAt: null i take: 2, inaczej null. Odczyt przed batchem |
| Widoczność | OK. Pola nie są w odpowiedzi POST, w getGameData ani w API graczy i gier |
HostClient.tsx |
OK bez zmian. Strona wysyła plik bez parsowania |
Twarde 2.0.0 w ingest |
OK. Tylko testy odrzucenia i komentarz |
| CI i konflikty | CI przechodzi. Brak konfliktu z main |
Drobne uwagi
- Brak testu dla zapytania Prisma w
createGameV2.ts:272-277. Test sprawdza czystą funkcję z mockiem. Przykład: ktoś usuwa...withoutDeleted, a testy dalej przechodzą. - Draft #346 ma też
0013_discord_host_permissions.sql. Przy rebase #346 musi zmienić numery na0014i wyższe.
Deploy
- Po merge każdy ręczny deploy prod z
main(także dla bota) wysyła serwer3.0.0. Wtedy stary host dostaje400na każdą grę. - Migracja jest addytywna i nullable. Można ją bezpiecznie zastosować na prod przed kodem (
npm run db:migrate:apply:production).
Review of #383. The D1 lookup for recorderPlayerId moves from createGameV2.ts to findLivePlayerIdsByFriendCode in recorder.ts. A new test makes sure that it filters deletedAt: null and takes at most two rows. If someone removes withoutDeleted, the test fails. Refs #377 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
DramaAferaStats.Client.dll 1.3.0+0370f42 from the client-v1.3.0 tag. The hat files stay the same. Goes live with the deploy of this branch. Refs #377 Co-Authored-By: Claude Opus 5.5 <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.
Merge i deploy tylko w oknie przełączenia, razem z hostem moda 1.2.0. Zod ma
.strict(): nowy host i stary serwer dają400, stary host i nowy serwer też dają400.Co się zmienia
gamesV2.ts:schemaVersion: z.literal('3.0.0')i wymaganerecorderFriendCode: z.string().min(1). Brak pola,nullalbo2.0.0daje400. Endpoint zostaje/api/v2/games.0013_game_recorder_friend_code.sql:games.recorderFriendCode(String?) igames.recorderPlayerId(Int?, relacja doplayers,ON DELETE SET NULL), indeks narecorderPlayerId. Migracja jest napisana ręcznie (ALTER TABLE ADD COLUMN). Powód:prisma migrate diffprzebudowuje całą tabelęgames. Po migracji diff Prisma jest pusty.createGameV2.ts, regułarecorderPlayerId(recorder.ts):Player.id.players(bez usuniętych) ma ten friend code: jegoid.NULL. Upload działa dalej.getGameDatai odpowiedźPOSTich nie pokazują (Player identity: the null case, merges, and what leaks publicly #287).HostClient.tsx: bez zmian. Strona wysyła tekst pliku bez parsowania, więc plik3.0.0działa. Kopia z okna przełączenia (host 1.1.3): admin zmieniaschemaVersionna3.0.0i dodajerecorderFriendCoderęcznie.aggregate.test.tsifixtures/v2-synthetic.jsondostają3.0.0.Numer migracji
mainma już0012_discord_accounts_emperor_polls.sql, więc ten PR używa0013. Draft PR #346 (0012–0015) robi rebase.Testy
npm run typecheck: OK.npm test: 156 passed. Nowe:gamesV2.test.ts(brak pola,null, puste,2.0.0),recorder.test.ts(trzy przypadki reguły),getGameData.test.ts(żadne z dwóch pól).npm run db:migrate:apply:local: OK.Closes #377
🤖 Generated with Claude Code