Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -329,18 +329,42 @@ async def add_exp(member_id):
|
|
| 329 |
# finding leaderboard rank + excluding huggingfolks (still need exclusion)
|
| 330 |
try:
|
| 331 |
print("Calculating rank...")
|
| 332 |
-
copy_df =
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
copy_df
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
except Exception as e:
|
| 343 |
-
print(f"
|
| 344 |
rank = "🤗"
|
| 345 |
|
| 346 |
# if level 3 -> then send embed, remove some exp
|
|
|
|
| 329 |
# finding leaderboard rank + excluding huggingfolks (still need exclusion)
|
| 330 |
try:
|
| 331 |
print("Calculating rank...")
|
| 332 |
+
copy_df = community_global_df.copy()
|
| 333 |
+
|
| 334 |
+
# check the initial DataFrame
|
| 335 |
+
print("Initial copy_df:\n", copy_df.head())
|
| 336 |
+
|
| 337 |
+
# discord_user_id to string
|
| 338 |
+
copy_df['discord_user_id'] = copy_df['discord_user_id'].astype(str).str.strip('L')
|
| 339 |
+
print("After processing discord_user_id:\n", copy_df['discord_user_id'].head())
|
| 340 |
+
|
| 341 |
+
# total_exp to int
|
| 342 |
+
copy_df['total_exp'] = copy_df['total_exp'].astype(str).str.strip('L').astype(int)
|
| 343 |
+
print("After processing total_exp:\n", copy_df['total_exp'].head())
|
| 344 |
+
|
| 345 |
+
# check processed DataFrame
|
| 346 |
+
print("Processed copy_df:\n", copy_df.head())
|
| 347 |
+
|
| 348 |
+
# if member_id exists in the DataFrame
|
| 349 |
+
if member_id in copy_df['discord_user_id'].values:
|
| 350 |
+
print(f"Member ID {member_id} found in the DataFrame.")
|
| 351 |
+
row = copy_df[copy_df['discord_user_id'] == str(member_id)]
|
| 352 |
+
print(f"Row for member_id {member_id}:\n", row)
|
| 353 |
+
|
| 354 |
+
# if the row is not empty
|
| 355 |
+
if not row.empty:
|
| 356 |
+
target_exp = row['total_exp'].values[0]
|
| 357 |
+
print(f"Target experience for {member_id}: {target_exp}")
|
| 358 |
+
rank = (copy_df['total_exp'] > target_exp).sum() + 1
|
| 359 |
+
print(f"The rank for {member} based on total_exp is: {rank}")
|
| 360 |
+
else:
|
| 361 |
+
print(f"Row for member_id {member_id} is empty.")
|
| 362 |
+
rank = "🤗"
|
| 363 |
+
else:
|
| 364 |
+
print(f"Discord ID {member} {member_id} not found in the DataFrame.")
|
| 365 |
+
rank = "🤗"
|
| 366 |
except Exception as e:
|
| 367 |
+
print(f"An error occurred: {e}")
|
| 368 |
rank = "🤗"
|
| 369 |
|
| 370 |
# if level 3 -> then send embed, remove some exp
|