Spaces:
Sleeping
Sleeping
Commit
·
df8e038
1
Parent(s):
b70c5bf
last 5 results
Browse files- app.py +24 -13
- leaders/users.json +1 -1
app.py
CHANGED
|
@@ -291,18 +291,20 @@ def display_leaderboard():
|
|
| 291 |
if st.button("Show Leaderboard"):
|
| 292 |
try:
|
| 293 |
# # Load the 'leaders' configuration
|
| 294 |
-
|
| 295 |
|
| 296 |
users_data = []
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
| 306 |
|
| 307 |
leaderboard = pd.DataFrame(users_data)
|
| 308 |
|
|
@@ -313,7 +315,7 @@ def display_leaderboard():
|
|
| 313 |
leaderboard['Rank'] = range(1, len(leaderboard) + 1)
|
| 314 |
|
| 315 |
# Select and order the columns for display
|
| 316 |
-
leaderboard = leaderboard[['Rank', 'User', 'Points']]
|
| 317 |
|
| 318 |
st.dataframe(leaderboard, hide_index=True)
|
| 319 |
except Exception as e:
|
|
@@ -438,19 +440,28 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
|
|
| 438 |
# Update points based on prediction accuracy
|
| 439 |
if predicted_winner == winning_team:
|
| 440 |
user_points += 2000 + bid_points
|
|
|
|
| 441 |
if predicted_motm == man_of_the_match:
|
| 442 |
user_points += 500
|
| 443 |
else:
|
| 444 |
user_points -= 200 + bid_points
|
|
|
|
| 445 |
else:
|
| 446 |
# Deduct 1000 points for not submitting a prediction
|
| 447 |
user_points -= 1000
|
|
|
|
| 448 |
|
| 449 |
-
|
| 450 |
-
|
| 451 |
|
| 452 |
# Update user's points in the DataFrame
|
| 453 |
users_df[user_name][0]['points'] = user_points
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
|
| 455 |
users.to_json(USERS_JSON)
|
| 456 |
updated_dataset = Dataset.from_pandas(users_df)
|
|
|
|
| 291 |
if st.button("Show Leaderboard"):
|
| 292 |
try:
|
| 293 |
# # Load the 'leaders' configuration
|
| 294 |
+
dataset = load_dataset("Jay-Rajput/DIS_IPL_Leads", split='train')
|
| 295 |
|
| 296 |
users_data = []
|
| 297 |
+
if dataset:
|
| 298 |
+
for user, points_dict in dataset[0].items():
|
| 299 |
+
points = points_dict.get("points", 0)
|
| 300 |
+
last_5_results = " ".join(points_dict.get("last_5_results", ["⚪"] * 5)) # Default: 5 white circles
|
| 301 |
+
users_data.append({'User': user, 'Points': points, "Last 5 Bids": last_5_results})
|
| 302 |
+
else:
|
| 303 |
+
data = load_users(USERS_JSON)
|
| 304 |
+
for user, points_dict in data.items():
|
| 305 |
+
points = points_dict.get("points", 0)
|
| 306 |
+
last_5_results = " ".join(points_dict.get("last_5_results", ["⚪"] * 5)) # Default: 5 white circles
|
| 307 |
+
users_data.append({'User': user, 'Points': points, "Last 5 Bids": last_5_results})
|
| 308 |
|
| 309 |
leaderboard = pd.DataFrame(users_data)
|
| 310 |
|
|
|
|
| 315 |
leaderboard['Rank'] = range(1, len(leaderboard) + 1)
|
| 316 |
|
| 317 |
# Select and order the columns for display
|
| 318 |
+
leaderboard = leaderboard[['Rank', 'User', 'Points', 'Last 5 Bids']]
|
| 319 |
|
| 320 |
st.dataframe(leaderboard, hide_index=True)
|
| 321 |
except Exception as e:
|
|
|
|
| 440 |
# Update points based on prediction accuracy
|
| 441 |
if predicted_winner == winning_team:
|
| 442 |
user_points += 2000 + bid_points
|
| 443 |
+
result_indicator = "🟢" # Correct Prediction
|
| 444 |
if predicted_motm == man_of_the_match:
|
| 445 |
user_points += 500
|
| 446 |
else:
|
| 447 |
user_points -= 200 + bid_points
|
| 448 |
+
result_indicator = "🔴" # Wrong Prediction
|
| 449 |
else:
|
| 450 |
# Deduct 1000 points for not submitting a prediction
|
| 451 |
user_points -= 1000
|
| 452 |
+
result_indicator = "⚪" # No Prediction
|
| 453 |
|
| 454 |
+
# Ensure user_points is never negative
|
| 455 |
+
user_points = max(user_points, 0)
|
| 456 |
|
| 457 |
# Update user's points in the DataFrame
|
| 458 |
users_df[user_name][0]['points'] = user_points
|
| 459 |
+
|
| 460 |
+
# Maintain last 5 prediction results
|
| 461 |
+
if "last_5_results" not in users_df[user_name][0]:
|
| 462 |
+
users_df[user_name][0]["last_5_results"] = []
|
| 463 |
+
users_df[user_name][0]["last_5_results"].insert(0, result_indicator) # Insert at beginning
|
| 464 |
+
users_df[user_name][0]["last_5_results"] = users_df[user_name][0]["last_5_results"][:5] # Keep only last 5
|
| 465 |
|
| 466 |
users.to_json(USERS_JSON)
|
| 467 |
updated_dataset = Dataset.from_pandas(users_df)
|
leaders/users.json
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"Arpit": {"points": 10000, "wildcard": [0, 0, 0]}, "Ganesh": {"points": 10000, "wildcard": [0, 0, 0]}, "Haaris": {"points": 10000, "wildcard": [0, 0, 0]}, "Jay": {"points": 10000, "wildcard": [0, 0, 0]}, "Kishore": {"points": 10000, "wildcard": [0, 0, 0]}, "Megha": {"points": 10000, "wildcard": [0, 0, 0]}, "Naveein": {"points": 10000, "wildcard": [0, 0, 0]}, "Neha": {"points": 10000, "wildcard": [0, 0, 0]}, "Praveen": {"points": 10000, "wildcard": [0, 0, 0]}, "Rakesh": {"points": 10000, "wildcard": [0, 0, 0]}, "Sai": {"points": 10000, "wildcard": [0, 0, 0]}, "Sahil": {"points": 10000, "wildcard": [0, 0, 0]}, "Sunil": {"points": 10000, "wildcard": [0, 0, 0]}, "Vaibhav": {"points": 10000, "wildcard": [0, 0, 0]}, "Vinay": {"points": 10000, "wildcard": [0, 0, 0]}}
|
|
|
|
| 1 |
+
{"Arpit": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Ganesh": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Haaris": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Jay": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Kishore": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Megha": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Naveein": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Neha": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Praveen": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Rakesh": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Sai": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Sahil": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Sunil": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Vaibhav": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}, "Vinay": {"points": 10000, "wildcard": [0, 0, 0],"last_5_results": ["⚪", "⚪", "⚪", "⚪", "⚪"]}}
|