From 93adf65a1800e425174562a82690c80964718381 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 11 May 2018 22:35:30 +0200 Subject: [PATCH] fireinfo: Only list countries on start page when >= 1% usage Signed-off-by: Michael Tremer --- webapp/backend/fireinfo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp/backend/fireinfo.py b/webapp/backend/fireinfo.py index bff06689..dd4aa506 100644 --- a/webapp/backend/fireinfo.py +++ b/webapp/backend/fireinfo.py @@ -1805,11 +1805,13 @@ class Fireinfo(Object): if res: return res.count - def get_geo_location_map(self, when=None): + def get_geo_location_map(self, when=None, minimum_percentage=1): res = self.db.query("WITH profiles AS (SELECT fireinfo_profiles_at(%s) AS id) \ SELECT location, COUNT(location)::float / (SELECT COUNT(*) FROM profiles) AS count FROM profiles \ LEFT JOIN fireinfo_profiles_locations ON profiles.id = fireinfo_profiles_locations.profile_id \ - WHERE fireinfo_profiles_locations.location IS NOT NULL GROUP BY location ORDER BY count DESC", when) + WHERE fireinfo_profiles_locations.location IS NOT NULL GROUP BY location \ + HAVING COUNT(location)::float / (SELECT COUNT(*) FROM profiles) >= %s ORDER BY count DESC", + when, minimum_percentage) return ((r.location, r.count) for r in res) -- 2.47.3