Browse Source

include latest tipped in cache load

master
lza_menace 3 months ago
parent
commit
017a230cc1
  1. 3
      suchwow/app.py
  2. 11
      suchwow/utils/helpers.py

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

11
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

Loading…
Cancel
Save