Use batch sizes, order by oldest first

This commit is contained in:
2011-05-24 11:52:11 +01:00
parent b44b384c51
commit 328736e239

View File

@@ -73,7 +73,7 @@ def queue_account_updates(update_delay=604800, batch_size=50):
# Update all the eve accounts and related corps # Update all the eve accounts and related corps
delta = timedelta(seconds=update_delay) delta = timedelta(seconds=update_delay)
log.info("Updating Accounts older than %s" % (datetime.now() - delta)) log.info("Updating Accounts older than %s" % (datetime.now() - delta))
accounts = RedditAccount.objects.filter(last_updated__lt=(datetime.now() - delta)) accounts = RedditAccount.objects.order_by('last_update').filter(last_update__lt=(datetime.now() - delta))[:batch_size]
log.info("%s account(s) to update" % accounts.count()) log.info("%s account(s) to update" % accounts.count())
for acc in accounts: for acc in accounts:
log.debug("Queueing Account %s for update" % acc.username) log.debug("Queueing Account %s for update" % acc.username)