fix: only contributors between hackathon dates
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from huggingface_hub.repocard import metadata_load
|
|
4 |
from gradio_client import Client
|
5 |
from PIL import Image, ImageDraw, ImageFont
|
6 |
|
7 |
-
from datetime import
|
8 |
import time
|
9 |
|
10 |
import os
|
@@ -23,6 +23,11 @@ CERTIFIED_USERS_FILENAME = "certified.csv"
|
|
23 |
|
24 |
ORGANIZATION = "pseudolab"
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
def has_contributions(repo_type, hf_username, organization, likes=10):
|
28 |
"""
|
@@ -39,7 +44,7 @@ def has_contributions(repo_type, hf_username, organization, likes=10):
|
|
39 |
}
|
40 |
|
41 |
for repo in repo_list[repo_type](author=organization):
|
42 |
-
if
|
43 |
continue
|
44 |
commits = api.list_repo_commits(repo.id, repo_type=repo_type)
|
45 |
if any(hf_username in commit.authors for commit in commits):
|
@@ -308,7 +313,7 @@ def leaderboard():
|
|
308 |
if repo.id.split('/')[-1] in not_included:
|
309 |
continue
|
310 |
commits = api.list_repo_commits(repo.id, repo_type=repo_type)
|
311 |
-
for author in set(author for commit in commits for author in commit.authors):
|
312 |
contributions[author].append((repo_type, repo.id, repo.likes))
|
313 |
|
314 |
leaderboard = []
|
|
|
4 |
from gradio_client import Client
|
5 |
from PIL import Image, ImageDraw, ImageFont
|
6 |
|
7 |
+
from datetime import datetime, timezone, timedelta
|
8 |
import time
|
9 |
|
10 |
import os
|
|
|
23 |
|
24 |
ORGANIZATION = "pseudolab"
|
25 |
|
26 |
+
# edge case of duplication of repos after the hackathon starts, but can't be avoided unless we ban duplication altogether
|
27 |
+
# TODO: Change this to 20th October 2023 after test is complete
|
28 |
+
START_DATE = datetime(2023, 10, 1, tzinfo=timezone(timedelta(hours=9)))
|
29 |
+
END_DATE = datetime(2023, 11, 10, tzinfo=timezone(timedelta(hours=9)))
|
30 |
+
|
31 |
|
32 |
def has_contributions(repo_type, hf_username, organization, likes=10):
|
33 |
"""
|
|
|
44 |
}
|
45 |
|
46 |
for repo in repo_list[repo_type](author=organization):
|
47 |
+
if repo.likes < likes:
|
48 |
continue
|
49 |
commits = api.list_repo_commits(repo.id, repo_type=repo_type)
|
50 |
if any(hf_username in commit.authors for commit in commits):
|
|
|
313 |
if repo.id.split('/')[-1] in not_included:
|
314 |
continue
|
315 |
commits = api.list_repo_commits(repo.id, repo_type=repo_type)
|
316 |
+
for author in set(author for commit in commits if START_DATE < commit.created_at < END_DATE for author in commit.authors):
|
317 |
contributions[author].append((repo_type, repo.id, repo.likes))
|
318 |
|
319 |
leaderboard = []
|