~edwargix/git.sr.ht

650294349b660546541336b7dc8cccc8b47b3b10 — Drew DeVault 7 years ago 48baad6
Handle case with no contributions in the past year
1 files changed, 6 insertions(+), 3 deletions(-)

M gitsrht/blueprints/stats.py
M gitsrht/blueprints/stats.py => gitsrht/blueprints/stats.py +6 -3
@@ 41,9 41,12 @@ def get_contributions(git_repo, tip, since):

def get_contrib_chart_data(contributions):
    # Max number of commits by a contributor in a single week
    max_commits = max(
        max(commits for _, commits in data['weekly'].items())
        for _, data in contributions.items())
    try:
        max_commits = max(
            max(commits for _, commits in data['weekly'].items())
            for _, data in contributions.items())
    except:
        max_commits = 0

    all_weeks = [_week(date.today() - timedelta(weeks=51 - n))
        for n in range(52)]