From 33ce001a6fa97716adbcbe921d59d35101d50b7e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 4 Jun 2020 18:01:47 +0200 Subject: [PATCH] Fix cvstats query --- royalpack/stars/api_cvstats_avg.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/royalpack/stars/api_cvstats_avg.py b/royalpack/stars/api_cvstats_avg.py index 0346fb3b..7748bb12 100644 --- a/royalpack/stars/api_cvstats_avg.py +++ b/royalpack/stars/api_cvstats_avg.py @@ -63,9 +63,7 @@ JOIN AVG(c.members_total) members_total, AVG(c.users_total) users_total FROM cvstats c - WHERE c.timestamp BETWEEN - NOW()::DATE-EXTRACT(DOW FROM NOW())::INTEGER-7 - AND NOW()::DATE-EXTRACT(DOW from NOW())::INTEGER + WHERE c.timestamp > current_timestamp - interval '7 day' GROUP BY h ) c GROUP BY ph @@ -92,9 +90,7 @@ JOIN AVG(c.members_total) members_total, AVG(c.users_total) users_total FROM cvstats c - WHERE c.timestamp BETWEEN - NOW()::DATE-EXTRACT(DOW FROM NOW())::INTEGER-30 - AND NOW()::DATE-EXTRACT(DOW from NOW())::INTEGER + WHERE c.timestamp > current_timestamp - interval '30 day' GROUP BY h ) c GROUP BY ph @@ -121,9 +117,7 @@ JOIN AVG(c.members_total) members_total, AVG(c.users_total) users_total FROM cvstats c - WHERE c.timestamp BETWEEN - NOW()::DATE-EXTRACT(DOW FROM NOW())::INTEGER-1 - AND NOW()::DATE-EXTRACT(DOW from NOW())::INTEGER + WHERE c.timestamp > current_timestamp - interval '1 day' GROUP BY h ) c GROUP BY ph