Read materialized player boards and accept Warden mode in army links - #66
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
clashking-api | bed5021 | Commit Preview URL Branch Preview URL |
Sep 17 2026, 04:25 AM |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Companion writer: ClashKingInc/ClashKingTracking#30; schema: ClashKingInc/DevKit#26. API CI is pinned to the immutable schema commit containing migration 020. Deploy only after Tracking has populated both views. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 298466be0e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| heroes.sort((a, b) => a.id - b.id || a.pet - b.pet | ||
| || (a.equipment.join("_") < b.equipment.join("_") ? -1 : a.equipment.join("_") > b.equipment.join("_") ? 1 : 0)) | ||
| const parts = heroes.length ? ["h" + heroes.map((hero) => `${hero.id}${hero.pet >= 0 ? `p${hero.pet}` : ""}${hero.equipment.length ? `e${hero.equipment.join("_")}` : ""}`).join("-")] : [] | ||
| const parts = heroes.length ? ["h" + heroes.map((hero) => `${hero.id}${hero.mode === undefined ? "" : `m${hero.mode}`}${hero.pet >= 0 ? `p${hero.pet}` : ""}${hero.equipment.length ? `e${hero.equipment.join("_")}` : ""}`).join("-")] : [] |
There was a problem hiding this comment.
Include mode when ordering hero entries
When an accepted code contains otherwise-identical hero entries that differ only by mode, the comparator returns zero while the newly emitted value includes mode, so input order leaks into the supposedly canonical result: h2m1-h2m0 and h2m0-h2m1 normalize differently. Because the normalized string is used for exact army_family_members.share_code lookups, a reordered equivalent query can incorrectly miss its family; include mode in the comparator or reject duplicate hero IDs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d70cb6fc6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const order = family === "townhall" ? "p.league_id DESC,p.trophies DESC,p.tag" : "p.trophies DESC,p.tag" | ||
| const rows = yield* sql.unsafe<PlayerLeaderboardRow>(`SELECT row_number() OVER (ORDER BY ${order})::integer AS rank, | ||
| const table = family === "townhall" ? "player_townhall_leaderboards" : "player_league_leaderboards" | ||
| const rows = yield* sql.unsafe<PlayerLeaderboardRow>(`SELECT p.rank, |
There was a problem hiding this comment.
Cast snapshot ranks back to numbers
PostgreSQL row_number() produces a bigint, which node-postgres returns as a string; the previous query explicitly used ::integer, but selecting p.rank directly removes that conversion. For any nonempty leaderboard, the request-level PlayerLeaderboardResponse encoder therefore receives a string for the required Schema.Number rank and returns UpstreamUnavailable instead of the board. Cast p.rank to an integer here or convert it before constructing the response.
Useful? React with 👍 / 👎.
|
Base-storage correction added in bed5021: Dashboard, mobile library and bot handlers now read/write inline images and votes on bases. Requires DevKit PR #26 migration 021; the pinned test schema includes it. Public response shapes are unchanged. Drain old base traffic, migrate, deploy this API, then resume; old handlers cannot use the dropped tables. Full 1,393 unit tests, typecheck/lint, 38 script tests and base PostgreSQL suites passed, including concurrent votes and sparse image staging. No production changes performed. |
Changes
Dependencies / rollout
Requires ClashKingInc/DevKit#26, then the companion Tracking implementation to populate both views. Deploy this API only after pg_matviews reports both populated. No production deployments, migrations or merges performed.
Validation
See docs/player-leaderboard-snapshots.md for deployment order and unchanged contracts.