From a63d4940ae387bea68b78e6f3a9a8edafd52b1c1 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Sep 2022 22:58:10 +0200 Subject: [PATCH] fix PCM /live list --- files/helpers/cron.py | 3 +-- files/routes/static.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 16a6b8fad..6f248f9fe 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -32,8 +32,7 @@ def cron(every_5m, every_1h, every_1d, every_1mo): spin_roulette_wheel() offsitementions.offsite_mentions_task() if SITE_NAME == 'PCM': - cache.delete_memoized(route_static.live_cached) - route_static.live_cached() + cache.set('live_cached', route_static.live_cached()) if every_1h: awards.award_timers_bots_task() diff --git a/files/routes/static.py b/files/routes/static.py index f52d07bee..620caa60f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -443,7 +443,6 @@ if SITE == 'pcmemes.net': live_thumb_regex = re.compile('\{"thumbnail":\{"thumbnails":\[\{"url":"(.*?)"', flags=re.A) offline_regex = re.compile('","title":"(.*?)".*?"width":48,"height":48\},\{"url":"(.*?)"', flags=re.A) - @cache.memoize(timeout=86400) def live_cached(): live = [] offline = [] @@ -475,15 +474,19 @@ if SITE == 'pcmemes.net': @app.get('/logged_out/live') @auth_desired_with_logingate def live(v): - return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1]) + live_cached = cache.get('live_cached') + + return render_template('live.html', v=v, live=live_cached[0], offline=live_cached[1]) @app.post('/live/add') @admin_level_required(2) def live_add(v): id = request.values.get('id') + live_cached = cache.get('live_cached') + if not id or len(id) != 24: - return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1], error="Invalid ID") + return render_template('live.html', v=v, live=live_cached[0], offline=live_cached[1], error="Invalid ID") existing = g.db.get(Streamer, id) if not existing: @@ -493,7 +496,7 @@ if SITE == 'pcmemes.net': if v.id != KIPPY_ID: send_repeatable_notification(KIPPY_ID, f"@{v.username} has added a [new YouTube channel](https://www.youtube.com/channel/{streamer.id})") - return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1], msg="Channel added successfuly!") + return render_template('live.html', v=v, live=live_cached[0], offline=live_cached[1], msg="Channel added successfuly!") @app.post('/live/remove') @admin_level_required(2) @@ -505,5 +508,6 @@ if SITE == 'pcmemes.net': if v.id != KIPPY_ID: send_repeatable_notification(KIPPY_ID, f"@{v.username} has removed a [YouTube channel](https://www.youtube.com/channel/{streamer.id})") g.db.delete(streamer) - + + live_cached = cache.get('live_cached') return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1], msg="Channel removed successfuly!") \ No newline at end of file