Jay-Rajput commited on
Commit
b70c5bf
·
1 Parent(s): df237d4

refactor ipl 2025

Browse files
Files changed (2) hide show
  1. app.py +2 -6
  2. matches.json +10 -0
app.py CHANGED
@@ -386,18 +386,14 @@ ADMIN_PASSPHRASE = "admin123"
386
  def fetch_latest_predictions(match_id):
387
  # Load the dataset. Adjust "split" to "train" or appropriate if "predictions" is a configuration.
388
  dataset = load_dataset("Jay-Rajput/DIS_IPL_Preds", split="train")
389
-
390
  # Convert the dataset to a pandas DataFrame
391
  df = pd.DataFrame(dataset)
392
-
393
  # Ensure the DataFrame is not empty and contains the required columns
394
  if not df.empty and {'user_name', 'match_id'}.issubset(df.columns):
395
  # Filter rows by 'match_id'
396
  filtered_df = df[df['match_id'] == match_id]
397
-
398
  # Drop duplicate rows based on 'user_name'
399
  unique_df = filtered_df.drop_duplicates(subset=['user_name'])
400
-
401
  return unique_df
402
  else:
403
  return pd.DataFrame()
@@ -432,7 +428,7 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
432
  # Update user points based on prediction accuracy
433
  users_with_predictions = set(predictions['user_name'])
434
  for user_name in users_df.columns:
435
- user_points = users_df[user_name][0]['0']
436
  if user_name in users_with_predictions:
437
  prediction = predictions[predictions['user_name'] == user_name].iloc[0]
438
  predicted_winner = prediction['predicted_winner']
@@ -454,7 +450,7 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
454
  user_points = 0
455
 
456
  # Update user's points in the DataFrame
457
- users_df[user_name][0]['0'] = user_points
458
 
459
  users.to_json(USERS_JSON)
460
  updated_dataset = Dataset.from_pandas(users_df)
 
386
  def fetch_latest_predictions(match_id):
387
  # Load the dataset. Adjust "split" to "train" or appropriate if "predictions" is a configuration.
388
  dataset = load_dataset("Jay-Rajput/DIS_IPL_Preds", split="train")
 
389
  # Convert the dataset to a pandas DataFrame
390
  df = pd.DataFrame(dataset)
 
391
  # Ensure the DataFrame is not empty and contains the required columns
392
  if not df.empty and {'user_name', 'match_id'}.issubset(df.columns):
393
  # Filter rows by 'match_id'
394
  filtered_df = df[df['match_id'] == match_id]
 
395
  # Drop duplicate rows based on 'user_name'
396
  unique_df = filtered_df.drop_duplicates(subset=['user_name'])
 
397
  return unique_df
398
  else:
399
  return pd.DataFrame()
 
428
  # Update user points based on prediction accuracy
429
  users_with_predictions = set(predictions['user_name'])
430
  for user_name in users_df.columns:
431
+ user_points = users_df[user_name][0]['points']
432
  if user_name in users_with_predictions:
433
  prediction = predictions[predictions['user_name'] == user_name].iloc[0]
434
  predicted_winner = prediction['predicted_winner']
 
450
  user_points = 0
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)
matches.json CHANGED
@@ -9,6 +9,16 @@
9
  ],
10
  "venue": "OTH"
11
  },
 
 
 
 
 
 
 
 
 
 
12
  {
13
  "match_id": "20250322_1",
14
  "date": "2025-03-22",
 
9
  ],
10
  "venue": "OTH"
11
  },
12
+ {
13
+ "match_id": "20250321_1",
14
+ "date": "2025-03-21",
15
+ "time": "12:00 PM",
16
+ "teams": [
17
+ "DIS",
18
+ "DIF"
19
+ ],
20
+ "venue": "OTH"
21
+ },
22
  {
23
  "match_id": "20250322_1",
24
  "date": "2025-03-22",