From c65cdc7b22e82cd16e75d295c74000f224288006 Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Tue, 29 Oct 2013 19:50:51 +0400 Subject: [PATCH] Company activity report is implemented * Added links to company report * Fixed punch-card to always show all days and all hours * Contribution details template is extracted into macro Change-Id: Ie9965f93dcd5d658b69bf38e6e947cd2f8ad6cdd --- dashboard/reports.py | 30 +++++++++++++++++ dashboard/templates/reports/base_report.html | 32 ++++++++++++++++--- .../templates/reports/company_activity.html | 24 ++++++++++++++ .../templates/reports/user_activity.html | 15 ++------- 4 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 dashboard/templates/reports/company_activity.html diff --git a/dashboard/reports.py b/dashboard/reports.py index fd69a0371..ba1a52abe 100644 --- a/dashboard/reports.py +++ b/dashboard/reports.py @@ -130,6 +130,12 @@ def _get_punch_card_data(records): if v: punch_card_data.append([hour, wday, v, v]) + # add corner point, otherwise chart doesn't know the bounds + if punch_card_raw[0][0] == 0: + punch_card_data.append([0, 0, 0, 0]) + if punch_card_raw[6][23] == 0: + punch_card_data.append([23, 6, 0, 0]) + return punch_card_data @@ -159,6 +165,30 @@ def user_activity(user_id): } +@blueprint.route('/companies/') +@decorators.templated() +@decorators.exception_handler() +def company_activity(company): + memory_storage_inst = vault.get_memory_storage() + original_name = memory_storage_inst.get_original_company_name(company) + + memory_storage_inst = vault.get_memory_storage() + records = memory_storage_inst.get_records( + memory_storage_inst.get_record_ids_by_companies([original_name])) + + activity = helpers.get_activity(records, 0, -1) + + punch_card_data = _get_punch_card_data(activity) + + return { + 'company': original_name, + 'activity': activity[:parameters.DEFAULT_STATIC_ACTIVITY_SIZE], + 'total_records': len(activity), + 'contribution': helpers.get_contribution_summary(activity), + 'punch_card_data': json.dumps(punch_card_data), + } + + @blueprint.route('/large_commits') @decorators.jsonify('commits') @decorators.exception_handler() diff --git a/dashboard/templates/reports/base_report.html b/dashboard/templates/reports/base_report.html index 8681b1459..388a9fd80 100644 --- a/dashboard/templates/reports/base_report.html +++ b/dashboard/templates/reports/base_report.html @@ -63,7 +63,8 @@

{{ item.date_str}} — commit “{{item.subject}}” to {{ item.module }}

-
Author: {{ item.author_name }} ({{ item.company_name }})
+
Author: {{ item.author_name }} + ({{ item.company_name }})
{{ item.message | safe }}
+{{ item.lines_added }} @@ -78,7 +79,10 @@

{{ item.date_str}} — review “{{item.subject}}” in {{ item.module }}

-
Patch submitted by: {{ item.parent_author_name }} ({{ item.parent_company_name }})
+
Reviewer: {{ item.author_name }} + ({{ item.company_name }})
+
Submitter: {{ item.parent_author_name }} + ({{ item.parent_company_name }})
Change Id: {{item.review_id}}
{{item.description}}: {{item.value}}
@@ -87,7 +91,8 @@

{{ item.date_str}} — patch “{{item.subject}}” posted into {{ item.module }}

-
Author: {{ item.author_name }} ({{ item.company_name }})
+
Author: {{ item.author_name }} + ({{ item.company_name }})
Current Status: {{ item.status }}
URL: {{item.url}}
Change Id: {{item.id}}
@@ -96,7 +101,8 @@

{{ item.date_str}} — email “{{item.subject}}”

-
Author: {{ item.author_name }} ({{ item.company_name }})
+
Author: {{ item.author_name }} + ({{ item.company_name }})
{% if item.body %}
{{ item.body|safe }}
{% endif %} @@ -105,7 +111,8 @@

{{ item.date_str}} — blueprint “{{item.title}}” in {{ item.module }}

-
Author: {{ item.author_name }} ({{ item.company_name }})
+
Author: {{ item.author_name }} + ({{ item.parent_company_name }})
Launchpad: https://blueprints.launchpad.net/{{ item.module }}/+spec/{{ item.name }}
Report: {{ item.blueprint_link | safe}}
{% if item.summary %} @@ -121,6 +128,21 @@ {%- endmacro %} +{% macro show_contribution_summary(contribution) -%} + +

Contribution summary

+
    +
  • Total commits: {{ contribution.commit_count }}
  • +
  • Total LOC: {{ contribution.loc }}
  • +
  • Review stat (-2, -1, +1, +2): {{ contribution.marks[-2] }}, {{ contribution.marks[-1] }}, + {{ contribution.marks[1] }}, {{ contribution.marks[2] }}
  • +
  • Draft Blueprints: {{ contribution.drafted_blueprint_count }}
  • +
  • Completed Blueprints: {{ contribution.completed_blueprint_count }}
  • +
  • Emails: {{ contribution.email_count }}
  • +
+ +{%- endmacro %} +
| community heartbeat diff --git a/dashboard/templates/reports/company_activity.html b/dashboard/templates/reports/company_activity.html new file mode 100644 index 000000000..110efa6f0 --- /dev/null +++ b/dashboard/templates/reports/company_activity.html @@ -0,0 +1,24 @@ +{% extends "reports/base_report.html" %} + +{% block title %} +{{ company }} activity report +{% endblock %} + +{% block head %} + +{% endblock %} + +{% block body %} +

{{ company }} activity report

+ +{{ show_contribution_summary(contribution) }} + +
+ +{{ show_activity_log(activity, false) }} + +{% endblock %} diff --git a/dashboard/templates/reports/user_activity.html b/dashboard/templates/reports/user_activity.html index e6a14aff0..9076de92b 100644 --- a/dashboard/templates/reports/user_activity.html +++ b/dashboard/templates/reports/user_activity.html @@ -15,21 +15,10 @@ {% block body %}

{{ user.user_name }} activity report

-

Contribution summary

-
    -
  • Total commits: {{ contribution.commit_count }}
  • -
  • Total LOC: {{ contribution.loc }}
  • -
  • Review stat (-2, -1, +1, +2): {{ contribution.marks[-2] }}, {{ contribution.marks[-1] }}, - {{ contribution.marks[1] }}, {{ contribution.marks[2] }}
  • -
  • Draft Blueprints: {{ contribution.drafted_blueprint_count }}
  • -
  • Completed Blueprints: {{ contribution.completed_blueprint_count }}
  • -
  • Emails: {{ contribution.email_count }}
  • -
+{{ show_contribution_summary(contribution) }}
-{% if activity %} - {{ show_activity_log(activity, false) }} -{% endif %} +{{ show_activity_log(activity, false) }} {% endblock %}