tasks: ignore inaccessible accounts for fetch as well
This commit is contained in:
parent
3ebb9476ef
commit
c54f6d0eee
3
tasks.py
3
tasks.py
|
@ -52,12 +52,13 @@ def fetch_acc(id, cursor=None):
|
||||||
fetch_acc.si(id, cursor).apply_async()
|
fetch_acc.si(id, cursor).apply_async()
|
||||||
finally:
|
finally:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
acc.last_fetch = db.func.now()
|
acc.touch_fetch()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def queue_fetch_for_most_stale_accounts(min_staleness=timedelta(minutes=5), limit=20):
|
def queue_fetch_for_most_stale_accounts(min_staleness=timedelta(minutes=5), limit=20):
|
||||||
accs = Account.query\
|
accs = Account.query\
|
||||||
|
.join(Account.tokens).group_by(Account)\
|
||||||
.filter(Account.last_fetch < db.func.now() - min_staleness)\
|
.filter(Account.last_fetch < db.func.now() - min_staleness)\
|
||||||
.order_by(db.asc(Account.last_fetch))\
|
.order_by(db.asc(Account.last_fetch))\
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
Loading…
Reference in New Issue