Fix some problems with off by one in the id condition when deleteing temporary access tokens.

This commit is contained in:
Jake Moshenko 2015-02-20 16:23:36 -05:00
parent f7b5221391
commit 24ab0ae53a

View file

@ -8,10 +8,10 @@ from app import app
logger = logging.getLogger(__name__)
BATCH_SIZE = 5000
BATCH_SIZE = 1000
def delete_temporary_access_tokens(older_than):
# Find the higest ID up to which we should delete
# Find the highest ID up to which we should delete
up_to_id = (AccessToken
.select(AccessToken.id)
.where(AccessToken.created < older_than)
@ -29,9 +29,9 @@ def delete_temporary_access_tokens(older_than):
start_time = datetime.utcnow()
(AccessToken
.delete()
.where(AccessToken.id > starting_at_id,
.where(AccessToken.id >= starting_at_id,
AccessToken.id < up_to_id,
AccessToken.temporary == 1,
AccessToken.temporary == True,
~(AccessToken.id << access_tokens_in_builds))
.execute())