handle case where we haven't scraped any posts yet i guess

This commit is contained in:
Lynne Megido 2019-09-11 15:26:28 +10:00
parent bb7c50a648
commit cfa32589d4

View File

@ -13,7 +13,8 @@ def scrape_posts(account):
c = db.cursor()
last_post = 0
c.execute("SELECT COUNT(*) FROM `posts` WHERE `fedi_id` = %s", (handle,))
if c.fetchone()[0] > 0:
count = c.fetchone()
if count is not None and count > 0:
# we've downloaded this user's posts before
# find out the most recently downloaded post of theirs
c.execute("SELECT `post_id` FROM `posts` WHERE `fedi_id` = %s ORDER BY `id` DESC LIMIT 1", (handle,))