Leaderboard and private chat - #71
Merged
Merged
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🧪 Coverage
|
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.
Description
Builds tier 1 of
docs/plan-future-features-roadmap.md: the leaderboard (§1) andplayer-to-player chat (§2), plus the pet-art and layout work that came out of using
them. 62 commits, 257 files.
Leaderboard
Ranks on the merged battle record, not on
pet_roster.win_count/loss_count.The roadmap's original proposal assumed the roster counters, which froze at §L Phase 6
when battles left the chain: ranking on them returns zero rows on this deployment.
docs/plan-future-features-roadmap.md§1 carries a "Built" banner recording thecorrection.
The merge happens inside the query rather than as an overlay afterwards, for the same
reason
findReadyOpponentsdoes it: the ordering is the merge, and an overlay appliedto a page can only rewrite rows the query already chose. The cost is no gRPC fast path,
since indexer-go's cache has no view of
pet_battle_progress.Worth review:
ROW_NUMBER()inside a subquery, with search applied outside it.A rank is a position on the whole board, so filtering before ranking would renumber
matches from one and a pet's rank would depend on what someone typed.
ILIKEmetacharacters are escaped. Without it a pet named100%matches everyrow. Verified against fixed values in the database.
which board indexes what. The player board aggregates its owners' pet names in the
ranked subquery and strips them from the result.
Podium membership follows
rank <= 3, so page 2 grows none and a searched leaderkeeps its medal.
Private chat (v1)
Married-pet threads:
chat_thread,chat_message,chat_read,chat_reaction, anotification-only WebSocket channel, and REST reads that reauthorize every time.
Worth review:
chat_threaddeliberately does notrecord the marriage that justifies it, so a divorce closes the conversation with no
revocation step that could be forgotten. A non-participant gets 404, not 403: 403
would confirm a thread id to anyone probing.
backend/src/ws/channel.ts).Constructing
new WebSocketServer({ server, path })per channel attaches one listenereach, so every connection is handled twice and the client gets two HTTP 101 responses.
That broke both channels, and per-channel tests could not catch it because each builds
its own server.
tests/ws/channel.test.tsis the regression test.than two per message.
thread-readandthread-reactedare distinct frame types. Both name a messagethe client already holds, which is the point of each, so folding them into
thread-updatedwould make every one look like the echo of the client's own send andno tick or reaction would ever appear.
offer what the API refuses, and it is append-only: a reaction is removed by tapping it
again, and that tap is validated against the list.
Verification
pnpm lintclean across backend, shared, protocol, verifier, frontend, website, mobile.814 backend, 480 shared and 377 frontend tests pass; backend and frontend build clean.
Behaviour that could not be tested in unit tests was checked against the live database
and in headless Chrome: ranks surviving a search, wildcard escaping, the read watermark
refusing to move backwards, the reaction toggle, and the panel and bubble layouts with a
control to prove the fix does the work.