From b54a26cf8fc1561662dd231609db2962bebee53e Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 9 Dec 2021 18:57:00 +0100 Subject: [PATCH] fix exception when no posts are in database Instead of using Query.one use Query.one_or_none. The check after setting the variable suggests this was the intended behaviour instead of throwing errors if there are no posts in the database. --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 07c7bf7..61fc555 100644 --- a/tasks.py +++ b/tasks.py @@ -428,7 +428,7 @@ def refresh_account_with_oldest_post(): AND NOT accounts.dormant ORDER BY posts.updated_at ASC LIMIT 1; - """).columns(Post.id, Post.author_id)).one() + """).columns(Post.id, Post.author_id)).one_or_none() if post: aid = post.author_id refresh_account(aid)