Skip to content

Commit

Permalink
Update fetch_stats.py
Browse files Browse the repository at this point in the history
  • Loading branch information
amazreech authored Jun 5, 2024
1 parent de69de7 commit 91c8156
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/fetch_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@

url = f"{GITHUB_API_URL}/repos/amazreech/{REPO_NAME}/stats/contributors"
print(f"URL: {url}")
response = requests.get(url, headers=headers)
print(f"response: {response}")

if response.status_code == 202:
print("Got 202, Wating...")
time.sleep(30)
while True:
response = requests.get(url, headers=headers)

if response.status_code == 200:
stats = response.json()
with open('repo_stats.json', 'w') as f:
json.dump(stats, f)
else:
print(f"Failed to fecth data: {response.status_code}")
exit(1)

if response.status_code == 200:
stats = response.json()
with open('repo_stats.json', 'w') as f:
json.dump(stats, f)
break

elif response.status_code == 202:
print("Got 202, Wating...")
time.sleep(30)

else:
print(f"Failed to fecth data: {response.status_code}")
break

0 comments on commit 91c8156

Please sign in to comment.