feat(server): update leaderboard scores from sync push

When a user pushes sync data and is opted in to the leaderboard, the
server now updates their leaderboard row with the merged stats using
MAX(best_score) and MIN(best_time_secs) — scores never regress even if
the client sends stale data.

Eliminates the need for a separate score-submission API call: the sync
push already carries the full stats, so the leaderboard stays current
after every push.

Added two integration tests:
- push_after_opt_in_updates_leaderboard_score
- push_lower_score_does_not_overwrite_leaderboard_best

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-04-26 23:56:49 +00:00
parent 3c01cef5f3
commit 303c78aa4c
4 changed files with 190 additions and 0 deletions
@@ -0,0 +1,20 @@
{
"db_name": "SQLite",
"query": "SELECT leaderboard_opt_in FROM users WHERE id = ?",
"describe": {
"columns": [
{
"name": "leaderboard_opt_in",
"ordinal": 0,
"type_info": "Integer"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false
]
},
"hash": "765c87463905b2edbf37f7416d5bc38e639c7e4c5feb0f5a9d8d6fb724e7a0a8"
}