From cf6386c33808b32c00c409b14329658f1ac12746 Mon Sep 17 00:00:00 2001 From: Vishal N Date: Wed, 17 Jan 2024 23:23:48 +0530 Subject: [PATCH] Refresh data on every request --- app.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 34fb557..8b6b99e 100644 --- a/app.py +++ b/app.py @@ -59,11 +59,18 @@ class Act: def __init__(self, num: int, name: str): self.num: int = num self.name: str = name - self.data: list = fetch_data(num) + self.data: list + + # Fetch data from leaderboard + self.refresh_leaderboard_data() + self.cabinet = list(filter(lambda member: member["Rating"] >= 5000, self.data)) self.members = list(filter(lambda member: member["Rating"] < 5000, self.data)) self.rank_members() + def refresh_leaderboard_data(self): + self.data = fetch_data(self.num) + def rank_members(self): for i, member in enumerate(self.members): if i < 1: @@ -102,6 +109,8 @@ def index(): @app.route("/leaderboard", methods=["GET"]) def leaderboard(): + for act in all_acts: + act.refresh_leaderboard_data() return render_template("leaderboard.html", all_acts=all_acts, enumerate=enumerate)