1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 08:38:59 +00:00

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() c = db.cursor()
last_post = 0 last_post = 0
c.execute("SELECT COUNT(*) FROM `posts` WHERE `fedi_id` = %s", (handle,)) 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 # we've downloaded this user's posts before
# find out the most recently downloaded post of theirs # 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,)) c.execute("SELECT `post_id` FROM `posts` WHERE `fedi_id` = %s ORDER BY `id` DESC LIMIT 1", (handle,))