lunarflu HF staff commited on
Commit
61bb569
1 Parent(s): 238d944

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -56,6 +56,7 @@ global_df = pd.DataFrame()
56
  worksheet2_df = pd.DataFrame()
57
  print(type(global_df))
58
  community_global_df = pd.DataFrame()
 
59
  data = pd.read_csv("https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/export?format=csv&gid=0")
60
  data2 = pd.read_csv("https://docs.google.com/spreadsheets/d/1T_twNONDSZ8zw7aDcYhw92DlawqPktti1xFw9ssJ13Y/export?format=csv&gid=0")
61
 
@@ -239,12 +240,12 @@ async def add_exp(member_id):
239
  current_role = lvls[current_level]
240
  if current_role not in member.roles: # if we leveled up
241
 
242
-
243
  try:
244
- # finding leaderboard rank
245
- row = community_global_df[community_global_df['discord_user_id'] == str(member_id)] # does this need to be string?
246
  target_exp = row['discord_exp'].values[0]
247
- rank = (community_global_df['discord_exp'] > target_exp).sum() + 1
248
  print(f"The rank for discord_id {member_id} based on discord_exp is: {rank}")
249
  except Exception as e:
250
  print(f"Discord ID {member_id} not found in the DataFrame.")
@@ -372,6 +373,7 @@ async def remove_huggingfolks():
372
  try:
373
  # remove huggingfolks
374
  global community_global_df
 
375
 
376
  community_global_df = global_df.copy()
377
 
@@ -382,8 +384,10 @@ async def remove_huggingfolks():
382
  for member_id in members_with_role:
383
  community_global_df = community_global_df[community_global_df.iloc[:, 0] != str(member_id)]
384
 
385
- #print(community_global_df)
 
386
 
 
387
  community_global_df.drop(community_global_df.columns[0], axis=1, inplace=True)
388
  community_global_df['discord_exp'] = pd.to_numeric(community_global_df['discord_exp'])
389
  community_global_df = community_global_df.nlargest(len(community_global_df), 'discord_exp')
 
56
  worksheet2_df = pd.DataFrame()
57
  print(type(global_df))
58
  community_global_df = pd.DataFrame()
59
+ community_global_df_with_id = pd.DataFrame()
60
  data = pd.read_csv("https://docs.google.com/spreadsheets/d/1hQSsIg1Y9WdBF_CdNM1L1rUUREoxKqRTe3_ILo-WK8w/export?format=csv&gid=0")
61
  data2 = pd.read_csv("https://docs.google.com/spreadsheets/d/1T_twNONDSZ8zw7aDcYhw92DlawqPktti1xFw9ssJ13Y/export?format=csv&gid=0")
62
 
 
240
  current_role = lvls[current_level]
241
  if current_role not in member.roles: # if we leveled up
242
 
243
+ # finding leaderboard rank + excluding huggingfolks
244
  try:
245
+ row = community_global_df_with_id[community_global_df_with_id['discord_user_id'] == member_id]
246
+ print(f"member id found")# does this need to be string?
247
  target_exp = row['discord_exp'].values[0]
248
+ rank = (community_global_df_with_id['discord_exp'] > target_exp).sum() + 1
249
  print(f"The rank for discord_id {member_id} based on discord_exp is: {rank}")
250
  except Exception as e:
251
  print(f"Discord ID {member_id} not found in the DataFrame.")
 
373
  try:
374
  # remove huggingfolks
375
  global community_global_df
376
+ global community_global_df_with_id
377
 
378
  community_global_df = global_df.copy()
379
 
 
384
  for member_id in members_with_role:
385
  community_global_df = community_global_df[community_global_df.iloc[:, 0] != str(member_id)]
386
 
387
+ # make a copy while discord id column still exists -> use for rank in discord embeds
388
+ community_global_df_with_id = community_global_df_with_id.copy()
389
 
390
+ # drop first column (discord id -> this is so we can display the important stuff in the leaderboard)
391
  community_global_df.drop(community_global_df.columns[0], axis=1, inplace=True)
392
  community_global_df['discord_exp'] = pd.to_numeric(community_global_df['discord_exp'])
393
  community_global_df = community_global_df.nlargest(len(community_global_df), 'discord_exp')