From bd574920b41eb96d274a0713a5853f2ba4f658fe Mon Sep 17 00:00:00 2001 From: codl Date: Sun, 13 Aug 2017 10:53:29 +0200 Subject: [PATCH] refresh task: ignore accounts with no tokens --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 3021d5c..7c0696f 100644 --- a/tasks.py +++ b/tasks.py @@ -183,7 +183,7 @@ def refresh_account_with_oldest_post(): @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() + acc = Account.query.join(Account.tokens).group_by(Account).having(db.func.count(OAuthToken.token) > 0).order_by(db.asc(Account.last_refresh)).first() refresh_account(acc.id)