summaryrefslogtreecommitdiff
path: root/apps/patchmetrics/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'apps/patchmetrics/views.py')
-rw-r--r--apps/patchmetrics/views.py49
1 files changed, 23 insertions, 26 deletions
diff --git a/apps/patchmetrics/views.py b/apps/patchmetrics/views.py
index 4a658e1..4c4d470 100644
--- a/apps/patchmetrics/views.py
+++ b/apps/patchmetrics/views.py
@@ -17,9 +17,8 @@ from patchmetrics.models import (
get_patches_accepted_by_age_range,
get_patches_per_month_up_to,
get_patches_waiting_for_feedback_by_age_range,
- get_submitted_patch_counts_for_month,
get_oldest_patches_waiting_for_feedback,
- get_overall_patch_count,
+ patch_month_metrics,
LinaroPatch,
PROJECTS_TO_IGNORE_IN_STATS,
Team)
@@ -39,14 +38,16 @@ def project(request, project_id):
request, project, 'patchmetrics.views.project',
view_args={'project_id': project.linkname},
should_show_move_form=True)
- now = datetime.now()
total, accepted = project.get_patch_count()
context['project'] = project
context['total_patches'] = total
context['accepted_patches'] = accepted
- context['patches_per_month_chart'] = get_patches_per_month_chart(
- project, now.year, now.month)
+ patches = LinaroPatch.objects.filter(project=project)
+
+ ticks, submitted, accepted = get_patches_per_month(patches)
+ context['patches_per_month_chart'] = generate_patches_per_month_chart(
+ ticks, submitted, accepted)
return render_to_response('patchmetrics/project.html', context)
@@ -68,14 +69,15 @@ def team(request, team_id):
request, None, 'patchmetrics.views.team',
view_args={'team_id': team.name}, patches=patches)
- now = datetime.now()
submitted, accepted = team.get_patch_count()
context['total_submitted'] = submitted
context['total_accepted'] = accepted
context['team'] = team
context['members'] = sorted(members, key=lambda member: member[1])
- context['patches_per_month_chart'] = get_patches_per_month_chart(
- team, now.year, now.month)
+ ticks, submitted, accepted = get_patches_per_month(team.patches)
+ context['patches_per_month_chart'] = generate_patches_per_month_chart(
+ ticks, submitted, accepted)
+
age_increment = 7
accepted = get_patches_accepted_by_age_range(
age_increment=age_increment, team=team)
@@ -138,7 +140,8 @@ def frontpage(request):
one_month_ago = datetime.now() - relativedelta.relativedelta(months=1)
year = one_month_ago.year
month = one_month_ago.month
- total, accepted = get_submitted_patch_counts_for_month(year, month)
+ ticks, submitted, accepted = get_patches_per_month(
+ LinaroPatch.objects.all())
total_waiting, old_waiting = get_number_of_patches_waiting_for_feedback()
projects = Project.objects.exclude(
linkname__in=PROJECTS_TO_IGNORE_IN_STATS)
@@ -151,14 +154,14 @@ def frontpage(request):
context['distinct_monthly_authors'] = get_distinct_author_count(
year, month)
context['total_accepted'] = get_number_of_patches_accepted()
- context['submitted_on_month'] = total
- context['submitted_and_accepted_on_month'] = accepted
+ context['submitted_on_month'] = submitted[-1][1]
+ context['submitted_and_accepted_on_month'] = accepted[-1][1]
context['waiting_for_feedback'] = total_waiting
context['more_than_30_days_old_waiting_for_feedback'] = old_waiting
context['old_patches_accepted_on_month'] = (
get_number_of_old_patches_accepted_on_month(year, month))
- context['patches_per_month_chart'] = get_overall_patches_per_month_chart(
- year, month)
+ context['patches_per_month_chart'] = generate_patches_per_month_chart(
+ ticks, submitted, accepted)
# days
age_increment = 15
new = get_patches_waiting_for_feedback_by_age_range(age_increment)
@@ -223,13 +226,6 @@ def get_patch_age_distribution_chart(data, age_increment, div_id, color=0):
return html
-def get_overall_patches_per_month_chart(year, month):
- submitted, accepted = get_patches_per_month_up_to(
- year, month, get_overall_patch_count, limit=8)
- ticks = [item[0] for item in submitted]
- return generate_patches_per_month_chart(ticks, submitted, accepted)
-
-
def generate_patches_per_month_chart(ticks, submitted, accepted, width=350,
height=250):
html = """
@@ -256,12 +252,13 @@ def generate_patches_per_month_chart(ticks, submitted, accepted, width=350,
return html
-def get_patches_per_month_chart(project_or_team, year, month):
- submitted, accepted = get_patches_per_month_up_to(
- year, month, project_or_team.get_patch_count, limit=8)
- ticks = [item[0] for item in submitted]
- return generate_patches_per_month_chart(
- ticks, submitted, accepted, width=500, height=250)
+def get_patches_per_month(patch_set):
+ metrics = patch_month_metrics(patch_set)
+ ticks = [x[0] for x in metrics]
+ submitted = [[x[0], x[1]] for x in metrics]
+ accepted = [[x[0], x[2]] for x in metrics]
+ return ticks, submitted, accepted
+ return generate_patches_per_month_chart(ticks, submitted, accepted)
def non_linaro_patches(request):