diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 16e6c42..47694da 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -4582,19 +4582,25 @@ def issues_history_stats(session, project): output = {} for week in range(53): start = tomorrow - datetime.timedelta(days=(week * 7)) - query = session.query( + closed_ticket = session.query( model.Issue ).filter( model.Issue.project_id == project.id ).filter( - sqlalchemy.or_( - model.Issue.closed_at == None, # noqa - model.Issue.closed_at <= start - ) + model.Issue.closed_at >= start + ).filter( + model.Issue.date_created <= start + ) + open_ticket = session.query( + model.Issue + ).filter( + model.Issue.project_id == project.id + ).filter( + model.Issue.status == 'Open' ).filter( model.Issue.date_created <= start ) - cnt = query.count() - to_ignore + cnt = open_ticket.count() + closed_ticket.count() - to_ignore if cnt < 0: cnt = 0 output[start.isoformat()] = cnt diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 2ceac32..d7a354d 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -2992,7 +2992,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): self.assertEqual(len(data), 1) self.assertEqual(len(data['stats']), 53) last_key = sorted(data['stats'].keys())[-1] - self.assertEqual(data['stats'][last_key], 8) + self.assertEqual(data['stats'][last_key], 7) for k in sorted(data['stats'].keys())[:-1]: self.assertEqual(data['stats'][k], 0)