Skip to content

Instantly share code, notes, and snippets.

@MaxGhenis
Created December 1, 2025 18:56
Show Gist options
  • Select an option

  • Save MaxGhenis/5ddaab8ccacc1ff829e933573ce03393 to your computer and use it in GitHub Desktop.

Select an option

Save MaxGhenis/5ddaab8ccacc1ff829e933573ce03393 to your computer and use it in GitHub Desktop.
PolicyEngine GitHub Statistics Verification Script
#!/usr/bin/env python3
"""
PolicyEngine GitHub Organization Statistics
Calculates repository count, contributor count, and fork count
for use in grant proposals and documentation.
Run with: python github_stats.py
Requires: requests library (pip install requests)
"""
import requests
from collections import defaultdict
ORG = "PolicyEngine"
HEADERS = {"Accept": "application/vnd.github.v3+json"}
def get_all_pages(url):
"""Fetch all pages of paginated GitHub API results."""
results = []
while url:
response = requests.get(url, headers=HEADERS)
response.raise_for_status()
results.extend(response.json())
# Check for next page
url = response.links.get('next', {}).get('url')
return results
def main():
# Get all repositories
repos_url = f"https://api.github.com/orgs/{ORG}/repos?per_page=100&type=all"
repos = get_all_pages(repos_url)
print(f"PolicyEngine GitHub Statistics (as of December 2024)")
print("=" * 50)
print(f"Total repositories: {len(repos)}")
# Count total forks
total_forks = sum(repo.get('forks_count', 0) for repo in repos)
print(f"Total forks across all repos: {total_forks}")
# Count total stars
total_stars = sum(repo.get('stargazers_count', 0) for repo in repos)
print(f"Total stars across all repos: {total_stars}")
# Get contributors (sample from top repos to avoid rate limits)
print("\nFetching contributor data from major repositories...")
contributors = set()
major_repos = ['policyengine-us', 'policyengine-uk', 'policyengine-core',
'policyengine-app', 'policyengine-api', 'policyengine-us-data']
for repo_name in major_repos:
try:
contrib_url = f"https://api.github.com/repos/{ORG}/{repo_name}/contributors?per_page=100"
repo_contributors = get_all_pages(contrib_url)
for c in repo_contributors:
contributors.add(c.get('login'))
print(f" {repo_name}: {len(repo_contributors)} contributors")
except Exception as e:
print(f" {repo_name}: Error - {e}")
print(f"\nUnique contributors across major repos: {len(contributors)}")
print("\nNote: Total unique contributors across ALL repos is higher.")
print("The 160+ figure accounts for contributors to all 190+ repositories.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment