]> git.ipfire.org Git - ipfire.org.git/commitdiff
fireinfo: Don't constantly wipe the log table
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2017 12:13:05 +0000 (13:13 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2017 12:13:05 +0000 (13:13 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
webapp/backend/fireinfo.py

index fb946b4c9e677283d904b1aaeb3bdcac85c4ad84..4529fea3275a2a5e19acc8f74e5c0117d0dda2c7 100644 (file)
@@ -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