def print_contributor_stats()

in analytics/github_analyze.py [0:0]


def print_contributor_stats(commits, delta: Optional[timedelta] = None) -> None:
    authors: Dict[str, int] = {}
    now = datetime.now()
    # Default delta is one non-leap year
    if delta is None:
        delta = timedelta(days=365)
    for commit in commits:
        date, author = commit.commit_date, commit.author
        if now - date > delta:
            break
        if author not in authors:
            authors[author] = 0
        authors[author] += 1

    print(f"{len(authors)} contributors made {sum(authors.values())} commits in last {delta.days} days")
    for count, author in sorted(((commit, author) for author, commit in authors.items()), reverse=True):
        print(f"{author}: {count}")