]> git.rm.cloudns.org Git - xonotic/xonstatdb.git/commitdiff
Add a script to refresh active maps.
authorAnt Zucaro <azucaro@gmail.com>
Tue, 2 Feb 2016 01:50:22 +0000 (20:50 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Tue, 2 Feb 2016 01:50:22 +0000 (20:50 -0500)
scripts/refresh_active_maps_mv.sql [new file with mode: 0644]

diff --git a/scripts/refresh_active_maps_mv.sql b/scripts/refresh_active_maps_mv.sql
new file mode 100644 (file)
index 0000000..c23ef50
--- /dev/null
@@ -0,0 +1,10 @@
+begin;
+    delete from active_maps_mv;
+
+    insert into active_maps_mv
+    select row_number() over(order by count(1) desc) sort_order, m.map_id, m.name, count(1) games
+    from maps m join games g on m.map_id = g.map_id
+    where g.create_dt >= now() at time zone 'UTC' - interval '1 week'
+    group by 2, 3
+    ;
+end;