mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
Rate-limited / 5xx / network failures were silently returning 0 from the
commit- and PR-count paths, then overwriting good values in fetcher.db —
turning a traffic spike into permanently-wrong "0 commits" cards. Raise
GitHubTransientError instead so the fetch aborts and the last-good row is
retained; genuine NOT_FOUND still yields 0.
Add a shared fetch-outcome counter (fetch_metrics table, spanning the web
workers and the cron container) surfaced at an unauthenticated GET /metrics
as ghstats_fetch_total{outcome="ok|not_found|rate_limited|error"}, so rate
limits are visible to the monitoring stack instead of dying silently.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fetcher Service
Owns every GitHub API interaction. Holds the PAT. Exposes cached payloads over an internal-only HTTP API protected by a shared secret.
Run locally
cd fetcher
pip install -r requirements.txt
FETCHER_INTERNAL_TOKEN=dev GITHUB_PAT=ghp_xxx python -m src.api
Cron (separate process):
FETCHER_INTERNAL_TOKEN=dev GITHUB_PAT=ghp_xxx python -m src.cron
Test
cd fetcher && pytest
Docker
docker build -t ghstats-fetcher .
docker run -e GITHUB_PAT=ghp_xxx -e FETCHER_INTERNAL_TOKEN=dev -p 5001:5001 -v $(pwd)/data:/app/data ghstats-fetcher
# cron: override CMD to ["python","-m","src.cron"]
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /health | none | health check |
| GET | /data/ | X-Internal-Token | return stored payload; auto-fetches on miss |
| POST | /fetch | X-Internal-Token | force re-fetch (body: {username}) |
| GET | /avatar/ | X-Internal-Token | proxied avatar bytes |
Env
See src/config.py.