Spaces:
Sleeping
Sleeping
Commit ·
afb5c0c
1
Parent(s): 0222c05
last 5 results
Browse filesFiles changed (2)
- app.py+24-13
- leaders/users.json+1-1
290 unmodified lines2912922932942952962972982993003013023033043053063073084 unmodified lines313314315316317318319118 unmodified lines438439440441442443444445446447448449450451452453454455456290 unmodified linesif st.button("Show Leaderboard"):try:# # Load the 'leaders' configuration# dataset = load_dataset("Jay-Rajput/DIS_IPL_Leads", split='train')users_data = []# if dataset:# for user, points_dict in dataset[0].items():# points = points_dict.get("points", 0)# users_data.append({'User': user, 'Points': points})# else:data = load_users(USERS_JSON)for user, points_dict in data.items():points = points_dict.get("points", 0)users_data.append({'User': user, 'Points': points})leaderboard = pd.DataFrame(users_data)4 unmodified linesleaderboard['Rank'] = range(1, len(leaderboard) + 1)# Select and order the columns for displayleaderboard = leaderboard[['Rank', 'User', 'Points']]st.dataframe(leaderboard, hide_index=True)except Exception as e:118 unmodified lines# Update points based on prediction accuracyif predicted_winner == winning_team:user_points += 2000 + bid_pointsif predicted_motm == man_of_the_match:user_points += 500else:user_points -= 200 + bid_pointselse:# Deduct 1000 points for not submitting a predictionuser_points -= 1000if user_points < 0:user_points = 0# Update user's points in the DataFrameusers_df[user_name][0]['points'] = user_pointsusers.to_json(USERS_JSON)updated_dataset = Dataset.from_pandas(users_df)290 unmodified lines2912922932942952962972982993003013023033043053063073083093104 unmodified lines315316317318319320321118 unmodified lines440441442443444445446447448449450451452453454455456457458459460461462463464465466467290 unmodified linesif st.button("Show Leaderboard"):try:# # Load the 'leaders' configurationdataset = load_dataset("Jay-Rajput/DIS_IPL_Leads", split='train')users_data = []if dataset:for user, points_dict in dataset[0].items():points = points_dict.get("points", 0)last_5_results = " ".join(points_dict.get("last_5_results", ["⚪"] * 5)) # Default: 5 white circlesusers_data.append({'User': user, 'Points': points, "Last 5 Bids": last_5_results})else:data = load_users(USERS_JSON)for user, points_dict in data.items():points = points_dict.get("points", 0)last_5_results = " ".join(points_dict.get("last_5_results", ["⚪"] * 5)) # Default: 5 white circlesusers_data.append({'User': user, 'Points': points, "Last 5 Bids": last_5_results})leaderboard = pd.DataFrame(users_data)4 unmodified linesleaderboard['Rank'] = range(1, len(leaderboard) + 1)# Select and order the columns for displayleaderboard = leaderboard[['Rank', 'User', 'Points', 'Last 5 Bids']]st.dataframe(leaderboard, hide_index=True)except Exception as e:118 unmodified lines# Update points based on prediction accuracyif predicted_winner == winning_team:user_points += 2000 + bid_pointsresult_indicator = "🟢" # Correct Predictionif predicted_motm == man_of_the_match:user_points += 500else:user_points -= 200 + bid_pointsresult_indicator = "🔴" # Wrong Predictionelse:# Deduct 1000 points for not submitting a predictionuser_points -= 1000result_indicator = "⚪" # No Prediction# Ensure user_points is never negativeuser_points = max(user_points, 0)# Update user's points in the DataFrameusers_df[user_name][0]['points'] = user_points# Maintain last 5 prediction resultsif "last_5_results" not in users_df[user_name][0]:users_df[user_name][0]["last_5_results"] = []users_df[user_name][0]["last_5_results"].insert(0, result_indicator) # Insert at beginningusers_df[user_name][0]["last_5_results"] = users_df[user_name][0]["last_5_results"][:5] # Keep only last 5users.to_json(USERS_JSON)updated_dataset = Dataset.from_pandas(users_df)
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": ["⚪", "⚪", "⚪", "⚪", "⚪"]}}
app.py+24-13
leaders/users.json+1-1