diff options
author | Ben Copeland <ben.copeland@linaro.org> | 2017-01-16 10:12:46 +0000 |
---|---|---|
committer | Linaro Code Review <review@review.linaro.org> | 2017-01-16 10:12:46 +0000 |
commit | ed91db3977d6e389e780da82ec661ed99a1251a1 (patch) | |
tree | a34fcdb29368bf526347b3624eb45b299781323d | |
parent | a806af75f51da914e4a25c91ccdfa94f855c570f (diff) | |
parent | 5e3f164172f6418062ae6ad384678577acb52081 (diff) |
Merge "linaro_metrics: Allow the Months Chart to be date selectable"
-rw-r--r-- | linaro_metrics/templates/linaro_metrics/team.html | 6 | ||||
-rw-r--r-- | linaro_metrics/views.py | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/linaro_metrics/templates/linaro_metrics/team.html b/linaro_metrics/templates/linaro_metrics/team.html index 60e01b0..d37df47 100644 --- a/linaro_metrics/templates/linaro_metrics/team.html +++ b/linaro_metrics/templates/linaro_metrics/team.html @@ -63,6 +63,12 @@ var ctx = document.getElementById("month_chart").getContext("2d"); var chart = new Chart(ctx).Line(monthChartData); </script> + <form method="GET"> + <select id="DataType" name="months" onchange="form.submit();"> + {% for month in months %} + <option value="{{ month }}"{% if month == returned_month %} selected{% endif %}>{{ month }} Months</option> + {% endfor %} + </select></form> </div> <div class="pure-u-2-5"> <strong>Time-to-acceptance distribution</strong> (in days) diff --git a/linaro_metrics/views.py b/linaro_metrics/views.py index 78dc67c..7272dff 100644 --- a/linaro_metrics/views.py +++ b/linaro_metrics/views.py @@ -123,18 +123,27 @@ def _non_project_ctx(request, view, view_args, patches): def team_view(request, team): team = get_object_or_404(Team, name=team) patches = Patch.objects.filter(teamcredit__team=team) - view_args = {'team': team.name} + month_choices = [6, 12, 18, 24] + + try: + month = int(request.GET.get('months', '6')) + except ValueError: + month = 6 + context = _non_project_ctx( request, 'linaro_metrics.views.team_view', view_args, patches) context.update({ 'team': team, 'memberships': TeamMembership.objects.filter(team=team), 'project': None, # Prevent trying to show project details in header. - 'metrics': TeamCredit.get_month_metrics(team=team), + 'metrics': TeamCredit.get_month_metrics(team=team, + num_months=month), 'acceptance': TeamCredit.time_to_acceptance(team=team), 'patches': patches, + 'months': month_choices, + 'returned_month': month, }) return render(request, 'linaro_metrics/team.html', context) |