From 84e0ad6b1fff23a57ad20b477fbea87abc71df9b Mon Sep 17 00:00:00 2001 From: codl Date: Sat, 9 Mar 2019 15:56:07 +0100 Subject: [PATCH] fix crash in fetch_acc when user has no posts --- tasks.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasks.py b/tasks.py index 789dffa..61be38c 100644 --- a/tasks.py +++ b/tasks.py @@ -155,11 +155,12 @@ def fetch_acc(id_): # we either finished the historic fetch # or we finished the current batch account.fetch_history_complete = True - account.fetch_current_batch_end_id = (Post.query - .with_parent(account, 'posts').order_by(db.desc(Post.created_at)).first()).id - # ^ note that this could be None if the user has no posts - # this is okay - + batch_end = (Post.query.with_parent(account, 'posts').order_by( + db.desc(Post.created_at)).first()) + if batch_end: + account.fetch_current_batch_end_id = batch_end.id + else: + account.fetch_current_batch_end_id = None db.session.commit() else: