include latest tipped in cache load

This commit is contained in:
lza_menace 2021-07-08 12:41:15 -07:00
parent c4dc5cd49a
commit 017a230cc1
2 changed files with 8 additions and 6 deletions

View file

@ -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)

View file

@ -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