-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.py
More file actions
27 lines (22 loc) · 689 Bytes
/
stats.py
File metadata and controls
27 lines (22 loc) · 689 Bytes
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
import requests
def fetch_repos(username):
url = f"https://api.github.com/users/{username}/repos"
response = requests.get(url)
if response.status_code != 200:
return None
return response.json()
def analyze_stats(repos):
languages = {}
stars = 0
for repo in repos:
lang = repo["language"]
if lang:
languages[lang] = languages.get(lang, 0) + 1
stars += repo["stargazers_count"]
main_lang = max(languages, key=languages.get) if languages else "Unknown"
return {
"repos": len(repos),
"stars": stars,
"main_language": main_lang,
"activity_score": len(repos) * 10 + stars
}