Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
revert rank stuff
Browse files
app.py
CHANGED
@@ -180,7 +180,6 @@ async def add_exp(member_id):
|
|
180 |
"""Uses member_id to create new record or update old one [member_id_column] ... [member_exp_column]"""
|
181 |
await asyncio.sleep(0.1)
|
182 |
global global_df
|
183 |
-
global community_global_df
|
184 |
|
185 |
guild = bot.get_guild(879548962464493619)
|
186 |
member = guild.get_member(member_id) # bot.get_user == User, guild.get_member == Member (not the same thing!)
|
@@ -330,46 +329,15 @@ async def add_exp(member_id):
|
|
330 |
# finding leaderboard rank + excluding huggingfolks (still need exclusion)
|
331 |
try:
|
332 |
print("Calculating rank...")
|
333 |
-
copy_df =
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
print("After processing discord_user_id:\n", copy_df['discord_user_id'].head())
|
341 |
-
print("Data type of discord_user_id:", copy_df['discord_user_id'].dtype)
|
342 |
-
|
343 |
-
# NaN -> 0
|
344 |
-
copy_df['total_exp'] = copy_df['total_exp'].fillna(0)
|
345 |
-
|
346 |
-
# total_exp to int
|
347 |
-
copy_df['total_exp'] = copy_df['total_exp'].astype(str).str.strip('L').astype(int)
|
348 |
-
print("After processing total_exp:\n", copy_df['total_exp'].head())
|
349 |
-
|
350 |
-
# check processed DataFrame
|
351 |
-
print("Processed copy_df:\n", copy_df.head())
|
352 |
-
|
353 |
-
# if member_id exists in the DataFrame
|
354 |
-
if str(member_id) in copy_df['discord_user_id'].values:
|
355 |
-
print(f"Member ID {member_id} found in the DataFrame.")
|
356 |
-
row = copy_df[copy_df['discord_user_id'] == str(member_id)]
|
357 |
-
print(f"Row for member_id {member_id}:\n", row)
|
358 |
-
|
359 |
-
# if the row is not empty
|
360 |
-
if not row.empty:
|
361 |
-
target_exp = row['total_exp'].values[0]
|
362 |
-
print(f"Target experience for {member_id}: {target_exp}")
|
363 |
-
rank = (copy_df['total_exp'] > target_exp).sum() + 1
|
364 |
-
print(f"The rank for {member} based on total_exp is: {rank}")
|
365 |
-
else:
|
366 |
-
print(f"Row for member_id {member_id} is empty.")
|
367 |
-
rank = "π€"
|
368 |
-
else:
|
369 |
-
print(f"Discord ID {member} {member_id} not found in the DataFrame.")
|
370 |
-
rank = "π€"
|
371 |
except Exception as e:
|
372 |
-
print(f"
|
373 |
rank = "π€"
|
374 |
|
375 |
# if level 3 -> then send embed, remove some exp
|
|
|
180 |
"""Uses member_id to create new record or update old one [member_id_column] ... [member_exp_column]"""
|
181 |
await asyncio.sleep(0.1)
|
182 |
global global_df
|
|
|
183 |
|
184 |
guild = bot.get_guild(879548962464493619)
|
185 |
member = guild.get_member(member_id) # bot.get_user == User, guild.get_member == Member (not the same thing!)
|
|
|
329 |
# finding leaderboard rank + excluding huggingfolks (still need exclusion)
|
330 |
try:
|
331 |
print("Calculating rank...")
|
332 |
+
copy_df = global_df.copy()
|
333 |
+
copy_df['discord_user_id'] = copy_df['discord_user_id'].str.strip('L').astype(str)
|
334 |
+
copy_df['total_exp'] = copy_df['total_exp'].str.strip('L').astype(int)
|
335 |
+
row = copy_df[copy_df['discord_user_id'] == str(member_id)]
|
336 |
+
target_exp = row['total_exp'].values[0]
|
337 |
+
rank = (copy_df['total_exp'] > target_exp).sum() + 1
|
338 |
+
print(f"The rank for {member} based on total_exp is: {rank}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
except Exception as e:
|
340 |
+
print(f"Discord ID {member} {member_id} not found in the DataFrame. {e}")
|
341 |
rank = "π€"
|
342 |
|
343 |
# if level 3 -> then send embed, remove some exp
|