add a task to refresh the account with the longest time since a refresh

This commit is contained in:
codl 2017-08-12 23:22:22 +02:00
parent efeb5b6f41
commit 74f20e3138
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 8 additions and 1 deletions

View File

@ -181,10 +181,17 @@ def refresh_account_with_oldest_post():
post = Post.query.options(db.joinedload(Post.author)).order_by(db.asc(Post.updated_at)).first()
refresh_account(post.author_id)
@app.task(autoretry_for=(TwitterError, URLError))
def refresh_account_with_longest_time_since_refresh():
acc = Account.query.order_by(db.asc(Account.last_refresh)).first()
refresh_account(acc.id)
app.add_periodic_task(30*60, periodic_cleanup)
app.add_periodic_task(45, queue_fetch_for_most_stale_accounts)
app.add_periodic_task(45, queue_deletes)
app.add_periodic_task(45, refresh_account_with_oldest_post)
app.add_periodic_task(90, refresh_account_with_oldest_post)
app.add_periodic_task(90, refresh_account_with_longest_time_since_refresh)
if __name__ == '__main__':
app.worker_main()