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)