Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
test
Browse files
app.py
CHANGED
|
@@ -53,106 +53,6 @@ def calculate_xp(level):
|
|
| 53 |
return (int(level ** 3))
|
| 54 |
|
| 55 |
|
| 56 |
-
# use a command
|
| 57 |
-
# check xp record presence (done in add_exp)
|
| 58 |
-
# check discord_user_id is verified
|
| 59 |
-
# do add_exp for hub?
|
| 60 |
-
"""
|
| 61 |
-
@bot.command(name='add_exp_hub')
|
| 62 |
-
async def add_exp_hub(ctx):
|
| 63 |
-
try:
|
| 64 |
-
column_values_7 = worksheet2.col_values(7)
|
| 65 |
-
column_values_3 = worksheet2.col_values(3)
|
| 66 |
-
|
| 67 |
-
for i, value in enumerate(column_values_7):
|
| 68 |
-
if not value:
|
| 69 |
-
print(f"cell empty, updating with likes")
|
| 70 |
-
hf_user_name = column_values_3[i]
|
| 71 |
-
print(f"hf_user_name = {hf_user_name}")
|
| 72 |
-
try:
|
| 73 |
-
likes = list_liked_repos(f"{hf_user_name}")
|
| 74 |
-
hf_likes_new = likes.total
|
| 75 |
-
print(f"hf_likes_new = {hf_likes_new}")
|
| 76 |
-
worksheet2.update(f'G{i+1}', f'{hf_likes_new}')
|
| 77 |
-
except Exception as e:
|
| 78 |
-
print(f"list_liked_repos Error: {e}")
|
| 79 |
-
|
| 80 |
-
except Exception as e:
|
| 81 |
-
print(f"add_exp_hub Error: {e}")
|
| 82 |
-
"""
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
"""
|
| 90 |
-
@bot.command(name='api_test')
|
| 91 |
-
async def api_test(ctx):
|
| 92 |
-
while True:
|
| 93 |
-
await periodic_api_test()
|
| 94 |
-
await asyncio.sleep(60) # Sleep for 60 seconds
|
| 95 |
-
"""
|
| 96 |
-
processed_users = set()
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
async def periodic_api_test():
|
| 100 |
-
try:
|
| 101 |
-
column_values_3 = worksheet2.col_values(3)
|
| 102 |
-
column_values_8 = worksheet2.col_values(8)
|
| 103 |
-
|
| 104 |
-
for i, user in enumerate(column_values_3):
|
| 105 |
-
if user in processed_users:
|
| 106 |
-
continue
|
| 107 |
-
|
| 108 |
-
url = f"https://huggingface.co/api/users/{user}/overview"
|
| 109 |
-
response = requests.get(url)
|
| 110 |
-
|
| 111 |
-
if response.status_code == 200:
|
| 112 |
-
data = response.json()
|
| 113 |
-
|
| 114 |
-
likes = data["numLikes"]
|
| 115 |
-
models = data["numModels"]
|
| 116 |
-
datasets = data["numDatasets"]
|
| 117 |
-
spaces = data["numSpaces"]
|
| 118 |
-
discussions = data["numDiscussions"]
|
| 119 |
-
papers = data["numPapers"]
|
| 120 |
-
upvotes = data["numUpvotes"]
|
| 121 |
-
|
| 122 |
-
worksheet2.update(values=[[likes, models, datasets, spaces, discussions, papers, upvotes]],
|
| 123 |
-
range_name=f'G{i+1}:M{i+1}')
|
| 124 |
-
|
| 125 |
-
processed_users.add(user)
|
| 126 |
-
else:
|
| 127 |
-
print(f"Failed to retrieve data for user {user}. Status code: {response.status_code}")
|
| 128 |
-
|
| 129 |
-
except Exception as e:
|
| 130 |
-
print(f"periodic_api_test Error: {e}")
|
| 131 |
-
|
| 132 |
-
"""
|
| 133 |
-
@bot.command(name='get_cell_value')
|
| 134 |
-
async def get_cell_value(ctx, row, col):
|
| 135 |
-
cell = worksheet2.cell(row, col)
|
| 136 |
-
print(cell.value)
|
| 137 |
-
"""
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
"""
|
| 141 |
-
@bot.command(name='check')
|
| 142 |
-
async def check(ctx):
|
| 143 |
-
try:
|
| 144 |
-
column_values_7 = worksheet2.col_values(7)
|
| 145 |
-
column_values_3 = worksheet2.col_values(3)
|
| 146 |
-
|
| 147 |
-
for i, value in enumerate(column_values_7):
|
| 148 |
-
print(i)
|
| 149 |
-
print(value)
|
| 150 |
-
|
| 151 |
-
except Exception as e:
|
| 152 |
-
print(f"add_exp_hub Error: {e}")
|
| 153 |
-
"""
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
async def add_exp(member_id):
|
| 158 |
try:
|
|
|
|
| 53 |
return (int(level ** 3))
|
| 54 |
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
async def add_exp(member_id):
|
| 58 |
try:
|