set max count to 100 users

This commit is contained in:
Bhupesh-V 2023-12-02 18:59:40 +05:30
parent 899674b01c
commit 8d9b7a9d34

View File

@ -18,19 +18,20 @@ def get_leaderboard_data():
data = response.json()
return data
def format_leaderboard(data, num_players=20):
def format_leaderboard(data, num_players=100):
leaderboard_stats = "r/developersIndia Advent of Code Leaderboard Stats\n\n"
leaderboard_stats += "| Rank | Player | Stars | Score |\n"
leaderboard_stats += "|------|--------|-------|-------|\n"
# Sort members by stars in descending order
sorted_members = sorted(data['members'].values(), key=lambda x: x['stars'], reverse=True)
sorted_members = sorted(data['members'].values(), key=lambda x: x['local_score'], reverse=True)
# Include only the top players
for i, member_data in enumerate(sorted_members[:num_players]):
leaderboard_stats += f"| {i + 1} | {member_data['name']} | {member_data['stars']} | {member_data['local_score']} |\n"
leaderboard_stats += f"\n[Advent of Code Leaderboard](https://adventofcode.com/2023/leaderboard/private/view/{aoc_leaderboard_code})\n"
leaderboard_stats += f"\nUpdated every 24 hours"
return leaderboard_stats