From 191087b67d74ce82e62adfb0d6206179fce0f989 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 1 Nov 2017 13:13:05 +0100 Subject: [PATCH] fireinfo: Don't constantly wipe the log table Signed-off-by: Michael Tremer --- webapp/backend/fireinfo.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/webapp/backend/fireinfo.py b/webapp/backend/fireinfo.py index fb946b4c..4529fea3 100644 --- a/webapp/backend/fireinfo.py +++ b/webapp/backend/fireinfo.py @@ -1503,12 +1503,9 @@ class Fireinfo(Object): return False def profile_rate_limit_active(self, public_id, when=None): - # Remove all outdated entries - self.db.execute("DELETE FROM fireinfo_profiles_log \ - WHERE ts <= then_or_now(%s) - INTERVAL '60 minutes'", when) - res = self.db.get("SELECT COUNT(*) AS count FROM fireinfo_profiles_log \ - WHERE public_id = %s", public_id) + WHERE public_id = %s AND ts >= then_or_now(%s) - INTERVAL '60 minutes'", + public_id, when) if res and res.count >= 10: return True -- 2.47.3