Merge pull request #170 from codl/fix-fetch-acc
fix crash in fetch_acc when user has no posts
This commit is contained in:
commit
fc06355bca
11
tasks.py
11
tasks.py
|
@ -155,11 +155,12 @@ def fetch_acc(id_):
|
||||||
# we either finished the historic fetch
|
# we either finished the historic fetch
|
||||||
# or we finished the current batch
|
# or we finished the current batch
|
||||||
account.fetch_history_complete = True
|
account.fetch_history_complete = True
|
||||||
account.fetch_current_batch_end_id = (Post.query
|
batch_end = (Post.query.with_parent(account, 'posts').order_by(
|
||||||
.with_parent(account, 'posts').order_by(db.desc(Post.created_at)).first()).id
|
db.desc(Post.created_at)).first())
|
||||||
# ^ note that this could be None if the user has no posts
|
if batch_end:
|
||||||
# this is okay
|
account.fetch_current_batch_end_id = batch_end.id
|
||||||
|
else:
|
||||||
|
account.fetch_current_batch_end_id = None
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue