-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
28 lines (21 loc) · 896 Bytes
/
api.py
File metadata and controls
28 lines (21 loc) · 896 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
28
from fastapi import FastAPI
from tracker.github_api import get_user_profile, get_user_repos
from tracker.score import get_recognition
app = FastAPI(
title="GitHub Contribution Tracker API",
description="Analyze GitHub contributors and assign Bronze/Silver/Gold/Platinum tiers",
version="1.0.0"
)
@app.get("/")
def home():
return {"message": "GitHub Contribution Tracker API", "version": "1.0.0"}
@app.get("/contributor/{username}")
def get_contributor_score(username: str):
profile = get_user_profile(username)
repos = get_user_repos(username)
total_stars = sum(repo.get("stargazers_count", 0) for repo in repos)
total_forks = sum(repo.get("forks_count", 0) for repo in repos)
prs = profile.get("public_repos", 0)
issues = profile.get("public_gists", 0)
result = get_recognition(username, prs, issues, total_stars, total_forks)
return result