service keys: fix stale query

This commit is contained in:
Jimmy Zelinskie 2016-03-30 18:27:44 -04:00 committed by Jimmy Zelinskie
parent bbaeaffbdb
commit c79bb14049

View file

@ -15,9 +15,9 @@ def _expired_keys_clause(service):
def _stale_unapproved_keys_clause(service):
return ((ServiceKey.service >> service) &
return ((ServiceKey.service == service) &
(ServiceKey.approval >> None) &
(ServiceKey.created_date + UNAPPROVED_TTL) >= datetime.utcnow())
(ServiceKey.created_date <= (datetime.utcnow() - UNAPPROVED_TTL)))
def _gc_expired(service):
@ -118,7 +118,7 @@ def _list_service_keys_query(kid=None, service=None, approved_only=False):
if service is not None:
query = query.where(ServiceKey.service == service)
query = query.where(~(_expired_keys_clause(service)) &
query = query.where(~(_expired_keys_clause(service)) |
~(_stale_unapproved_keys_clause(service)))
if kid is not None: