]> git.rm.cloudns.org Git - xonotic/xonstatdb.git/commitdiff
Small transaction to regenerate ranks.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 22 Jan 2012 03:54:41 +0000 (22:54 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 22 Jan 2012 03:54:41 +0000 (22:54 -0500)
scripts/update_ranks.sql [new file with mode: 0644]

diff --git a/scripts/update_ranks.sql b/scripts/update_ranks.sql
new file mode 100644 (file)
index 0000000..66e8b12
--- /dev/null
@@ -0,0 +1,10 @@
+begin;
+    delete from player_ranks;
+
+    insert into player_ranks(player_id, nick, game_type_cd, elo, rank)
+    select p.player_id, p.nick, pe.game_type_cd, pe.elo, rank() 
+    over (partition by pe.game_type_cd order by pe.elo desc)
+    from players p, player_elos pe
+    where p.player_id = pe.player_id;
+
+end;