From 017a230cc1e8be5af020bf1cebf4bf0ab2addc67 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 8 Jul 2021 12:41:15 -0700 Subject: [PATCH] include latest tipped in cache load --- suchwow/app.py | 3 +++ suchwow/utils/helpers.py | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/suchwow/app.py b/suchwow/app.py index 7431f92..e068265 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -172,6 +172,9 @@ def load_cache(): app.logger.info('loading top posters into cache') get_top_posters() app.logger.info('done') + app.logger.info('loading latest tipped into cache') + get_latest_tipped_posts() + app.logger.info('done') for i in [1, 3, 7, 30]: app.logger.info(f'loading top posts last {i} days into cache') get_top_posts(i) diff --git a/suchwow/utils/helpers.py b/suchwow/utils/helpers.py index 87bad3d..f2b8796 100644 --- a/suchwow/utils/helpers.py +++ b/suchwow/utils/helpers.py @@ -43,10 +43,9 @@ def post_webhook(msg): def get_latest_tipped_posts(): key_name = 'latest_tips' - tipped_posts = rw_cache(key_name, None, 1200) - + posts = [] + tipped_posts = rw_cache(key_name) if not tipped_posts: - new_data = [] w = Wallet() data = {} for acc in w.accounts(): @@ -61,10 +60,10 @@ def get_latest_tipped_posts(): dates = sorted(data, reverse=True) for d in dates: - if not data[d] in new_data: - new_data.append(data[d]) + if not data[d] in posts: + posts.append(data[d]) - tipped_posts = rw_cache(key_name, new_data, 1200) + tipped_posts = rw_cache(key_name, posts) return tipped_posts