Skip to content

Commit dc887e2

Browse files
committed
Modify update frequency and handle empty repos
1 parent 8f022f6 commit dc887e2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

datauploader/api/rest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ def get_repo_commits_for_user(github_access_token, repo, username, sync_after_da
109109
response = rr.get(url, headers=get_auth_header(github_access_token), realms=['github'])
110110
commits = json.loads(response.content)
111111

112+
if not isinstance(commits, list):
113+
print("Got unexpected response from API - repo may be empty, will skip")
114+
print(commits)
115+
return [], None
116+
112117
if latest_commit_date is None and len(commits) > 0:
113118
# github returns the data in descending chronological order
114119
# date is in the format 2014-05-09T15:14:07Z
@@ -184,6 +189,7 @@ def from_API(self, token, existing_data):
184189
repo_commits, latest_date = get_repo_commits_for_user(token, repo_name, username, sync_after_date=last_existing_commit_date)
185190
print("Fetched {} new commits".format(len(repo_commits)))
186191

192+
187193
if existing_data:
188194
repo_commits = repo_commits + existing_data.get_commits_for_repo(repo_name)
189195

main/management/commands/update_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Command(BaseCommand):
1111
def handle(self, *args, **options):
1212
users = DataSourceMember.objects.all()
1313
for github_user in users:
14-
if github_user.last_updated < (arrow.now() - timedelta(days=4)):
14+
if github_user.last_updated < (arrow.now() - timedelta(days=1)):
1515
print("Updating user {}".format(github_user.user.oh_id))
1616
oh_id = github_user.user.oh_id
1717
process_github.delay(oh_id)

0 commit comments

Comments
 (0)