Skip to content

Commit

Permalink
Refresh data on every request
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnandagopal committed Jan 17, 2024
1 parent a051dfe commit cf6386c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit cf6386c

Please sign in to comment.