[server] avg_time_seconds merge produces wrong value when losing side has more wins #23
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File
solitaire_sync/src/merge.rslines 116–127Description
The merge takes
max(local_total_time, remote_total_time)and divides bymax(games_won). This misattributes time when the device with more wins has a lower total time.Example: local has 100 wins × 300 s avg (total = 30,000 s); remote has 50 wins × 1,000 s avg (total = 50,000 s). Merge gives
50,000 / 100 = 500 s/win— but the correct average for the 100-win device is 300 s.Additionally,
games_lostis merged withmax()independently ofgames_playedandgames_won, so after a divergent mergegames_won + games_lost > games_playedis possible, producing win rates above 100%.Fix
For
avg_time_seconds: use the average from whichever side contributedmerged_games_won. Forgames_lost: derive it asmerged_games_played - merged_games_wonafter merging, rather than takingmax()independently.