Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
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