]> de.git.xonotic.org Git - xonotic/xonstatdb.git/blob - scripts/update_ranks.sql
77c7c796ac1f986ed1f4548028533908e7ad060b
[xonotic/xonstatdb.git] / scripts / update_ranks.sql
1 begin;
2     -- save the history
3     insert into player_ranks_history
4     select * from player_ranks;
5
6     -- get rid of the existing ranks and refresh them using
7     -- the latest elo information for each game type
8     delete from player_ranks;
9
10     insert into player_ranks(player_id, nick, game_type_cd, elo, rank)
11     select p.player_id, p.nick, pe.game_type_cd, pe.elo, rank() 
12     over (partition by pe.game_type_cd order by pe.elo desc)
13     from players p, player_elos pe
14     where p.player_id = pe.player_id
15     and p.active_ind = 'Y'
16     and pe.games > 32;
17
18 end;