From: Ant Zucaro Date: Tue, 2 Feb 2016 01:50:22 +0000 (-0500) Subject: Add a script to refresh active maps. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ea835df69294da97f1bfa5e93f47f8e7317ee526;p=xonotic%2Fxonstatdb.git Add a script to refresh active maps. --- diff --git a/scripts/refresh_active_maps_mv.sql b/scripts/refresh_active_maps_mv.sql new file mode 100644 index 0000000..c23ef50 --- /dev/null +++ b/scripts/refresh_active_maps_mv.sql @@ -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;