-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_stats.py
More file actions
64 lines (51 loc) · 1.89 KB
/
test_stats.py
File metadata and controls
64 lines (51 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Test script to verify the stats calculation logic
Run this locally to test before pushing the workflow
"""
import os
import requests
# You'll need to set your GitHub token as an environment variable
# Or replace this with your token (for testing only - don't commit tokens!)
token = os.environ.get('GITHUB_TOKEN') or input("Enter your GitHub token (or set GITHUB_TOKEN env var): ").strip()
username = 'certainly-param'
if not token:
print("Error: GitHub token is required")
exit(1)
# Fetch all repositories
print(f"Fetching all repositories for {username}...")
total_stars = 0
total_forks = 0
page = 1
per_page = 100
headers = {
'Authorization': f'token {token}',
'Accept': 'application/vnd.github.v3+json'
}
while True:
url = f'https://api.github.com/users/{username}/repos?per_page={per_page}&page={page}&type=all'
response = requests.get(url, headers=headers)
response.raise_for_status()
repos = response.json()
if not repos:
break
for repo in repos:
stars = repo.get('stargazers_count', 0)
forks = repo.get('forks_count', 0)
total_stars += stars
total_forks += forks
print(f" {repo['name']}: {stars} stars, {forks} forks")
print(f"Page {page}: Processed {len(repos)} repos. Running totals - Stars: {total_stars}, Forks: {total_forks}")
if len(repos) < per_page:
break
page += 1
print(f"\n{'='*50}")
print(f"Final totals:")
print(f" Total Stars: {total_stars}")
print(f" Total Forks: {total_forks}")
print(f"{'='*50}")
# Show what the badges will look like
stars_badge = f""
forks_badge = f""
print(f"\nBadge URLs:")
print(f" {stars_badge}")
print(f" {forks_badge}")