From ea835df69294da97f1bfa5e93f47f8e7317ee526 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Mon, 1 Feb 2016 20:50:22 -0500 Subject: [PATCH] Add a script to refresh active maps. --- scripts/refresh_active_maps_mv.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 scripts/refresh_active_maps_mv.sql 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; -- 2.39.2