Skip to content

Commit 232bfa3

Browse files
committed
fix: global time leaderboard tick rounding being wrong
1 parent 5f2c295 commit 232bfa3

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

internal/mapdb/queries/leaderboards.sql

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@ where deleted is null
2222
and maps.published_at is not null;
2323

2424
-- name: GetTopTimesLeaderboard :many
25-
select s1.player_id,
26-
count(distinct s1.map_id) as top_times
27-
from (select map_id, min((round(greatest(playtime, ticks * 20) / 50.0) * 50)::bigint) as min_playtime
28-
from save_states
25+
with
26+
shortest_playtimes as (
27+
select map_id, min((greatest(round(playtime / 50.0), ticks) * 50)::bigint) as min_playtime
28+
from save_states
2929
join maps on save_states.map_id = maps.id
30-
where deleted is null
31-
and completed = true
32-
and playtime != 0
33-
and (type = 'playing' or type = 'verifying')
34-
and maps.published_at is not null
35-
and maps.deleted_at is null
36-
and coalesce(maps.leaderboard ->> 'format', 'time') = 'time'
37-
group by map_id) as shortest_playtimes
30+
where deleted is null
31+
and completed = true
32+
and playtime != 0
33+
and (type = 'playing' or type = 'verifying')
34+
and maps.published_at is not null
35+
and maps.deleted_at is null
36+
and coalesce(maps.leaderboard ->> 'format', 'time') = 'time'
37+
and coalesce(maps.leaderboard ->> 'asc', 'true') = 'true'
38+
group by map_id
39+
)
40+
select s1.player_id, count(distinct s1.map_id) as top_times
41+
from shortest_playtimes
3842
join save_states as s1
3943
on s1.map_id = shortest_playtimes.map_id
40-
and (round(greatest(s1.playtime, s1.ticks * 20) / 50.0) * 50)::bigint = shortest_playtimes.min_playtime
44+
and (greatest(round(s1.playtime / 50.0), s1.ticks) * 50)::bigint = shortest_playtimes.min_playtime
4145
where s1.deleted is null
4246
and s1.completed = true
4347
group by s1.player_id

0 commit comments

Comments
 (0)