diff --git a/src/quota/sql.py b/src/quota/sql.py index 7579aa3b0..f7e68975d 100644 --- a/src/quota/sql.py +++ b/src/quota/sql.py @@ -38,7 +38,7 @@ UPDATE quota_limits SET available=available+?, revoked_at=datetime('now') WHERE subject=? - AND revoked_at < datetime('now', ?); + AND datetime(revoked_at, ?) <= datetime('now'); """ @@ -54,7 +54,7 @@ UPDATE quota_limits SET available=?, revoked_at=datetime('now') WHERE subject=? - AND revoked_at < datetime('now', ?); + AND datetime(revoked_at, ?) <= datetime('now'); """ INIT_QUOTA_PG = """ diff --git a/src/runners/quota_scheduler.py b/src/runners/quota_scheduler.py index ac7a8cd22..3d260b07b 100644 --- a/src/runners/quota_scheduler.py +++ b/src/runners/quota_scheduler.py @@ -217,7 +217,8 @@ def quota_revocation( subject_id = get_subject_id(quota_limiter.type) - if quota_limiter.quota_increase is not None: + # do not update quota revocation date when the increase is set to zero + if quota_limiter.quota_increase is not None and quota_limiter.quota_increase > 0: increase_quota( connection, increase_quota_statement, @@ -226,6 +227,7 @@ def quota_revocation( quota_limiter.period, ) + # do not update quota revocation date when the initial quota is set to zero if quota_limiter.initial_quota is not None and quota_limiter.initial_quota > 0: reset_quota( connection,