From 765f681cecfcd2ca0d0de5a3a44d30e7476277e6 Mon Sep 17 00:00:00 2001 From: jwansek Date: Fri, 8 Sep 2023 18:09:15 +0000 Subject: Fixed bug in fetching tweets SQL command --- database.py | 14 +++++++++----- services.py | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) mode change 100755 => 100644 database.py diff --git a/database.py b/database.py old mode 100755 new mode 100644 index ea3835c..f3a181c --- a/database.py +++ b/database.py @@ -135,7 +135,7 @@ class Database: def get_cached_tweets(self, numToGet = None): with self.__connection.cursor() as cursor: - sql = "SELECT tweet, tweet_id, account FROM diary WHERE account = %s ORDER BY tweeted_at" + sql = "SELECT tweet, tweet_id, account FROM diary WHERE account = %s ORDER BY tweeted_at DESC" args = (self.config.get("twitter", "main_account"), ) if numToGet is not None: sql += " LIMIT %s;" @@ -330,8 +330,12 @@ def update_cache(): for image in images: db.append_diary_images(id_, image) print("Finished getting diary tweets...") + main_account = db.config.get("twitter", "main_account") + oldest_tweet = db.get_newest_diary_tweet_id(main_account) + print("Fetching tweets from account '%s' older than %d" % (main_account, oldest_tweet)) for id_, dt, replying_to, text, username, images in services.scrape_nitter( - db.config.get("twitter", "main_account"), db.get_newest_diary_tweet_id(db.config.get("twitter", "main_account")) + main_account, + oldest_tweet ): db.append_diary(id_, dt, replying_to, text, username) for image in images: @@ -340,7 +344,7 @@ def update_cache(): if __name__ == "__main__": - with Database() as db: - print(db.get_cached_tweets()) + #with Database() as db: + # print(db.get_cached_tweets(7)) - # update_cache() + update_cache() diff --git a/services.py b/services.py index ee98677..9bbac3f 100755 --- a/services.py +++ b/services.py @@ -330,7 +330,7 @@ def parse_tweet(tweet_url): if __name__ == "__main__": # print(get_trans_stats()) - print(scrape_nitter(CONFIG.get("twitter", "diary_account"), 1697430888617840909)) + #print(scrape_nitter(CONFIG.get("twitter", "diary_account"), 1697430888617840909)) print(scrape_nitter("estrogenizedboy", 1698107440489734640)) - # print(parse_tweet("https://nitter.net/HONMISGENDERER/status/1694231618443981161#m")) \ No newline at end of file + # print(parse_tweet("https://nitter.net/HONMISGENDERER/status/1694231618443981161#m")) -- cgit v1.2.3