Refactoring of contribution summary block
* Removed code duplication * Contribution summary block is loaded via AJAX in activity reports Change-Id: I89eeace7a90ebc2c3998ee354dfe943b2b8e3cbe
This commit is contained in:
parent
80aad63d4c
commit
ee12823a6a
@ -170,21 +170,16 @@ def _get_punch_card_data(records):
|
|||||||
def _get_activity_summary(record_ids):
|
def _get_activity_summary(record_ids):
|
||||||
memory_storage_inst = vault.get_memory_storage()
|
memory_storage_inst = vault.get_memory_storage()
|
||||||
|
|
||||||
types = ['mark', 'patch', 'email', 'bpd', 'bpc', 'commit']
|
types = ['mark', 'patch', 'email', 'bpd', 'bpc']
|
||||||
record_ids_by_type = set()
|
record_ids_by_type = set()
|
||||||
for t in types:
|
for t in types:
|
||||||
record_ids_by_type |= memory_storage_inst.get_record_ids_by_type(t)
|
record_ids_by_type |= memory_storage_inst.get_record_ids_by_type(t)
|
||||||
|
|
||||||
record_ids &= record_ids_by_type
|
record_ids &= record_ids_by_type
|
||||||
contribution_summary = helpers.get_contribution_summary(
|
|
||||||
memory_storage_inst.get_records(record_ids))
|
|
||||||
|
|
||||||
record_ids -= memory_storage_inst.get_record_ids_by_type('commit')
|
|
||||||
punch_card_data = _get_punch_card_data(
|
punch_card_data = _get_punch_card_data(
|
||||||
memory_storage_inst.get_records(record_ids))
|
memory_storage_inst.get_records(record_ids))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'contribution': contribution_summary,
|
|
||||||
'punch_card_data': punch_card_data,
|
'punch_card_data': punch_card_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
dashboard/templates/_macros/contribution_summary.html
Normal file
44
dashboard/templates/_macros/contribution_summary.html
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{% macro show_contribution_summary(user_id=None, company=None, show_all=True) -%}
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function load_contribution_summary(extra_options) {
|
||||||
|
$.ajax({
|
||||||
|
url: make_uri("/api/1.0/contribution", extra_options),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
$("#contribution_template").tmpl(data["contribution"]).appendTo("#contribution_container");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
var uri_options = {};
|
||||||
|
{% if show_all %}
|
||||||
|
uri_options = {project_type: "all", release: "all", metric: "all"};
|
||||||
|
{% endif %}
|
||||||
|
{% if user_id %}
|
||||||
|
uri_options["user_id"] = "{{ user_id }}";
|
||||||
|
{% endif %}
|
||||||
|
{% if company %}
|
||||||
|
uri_options["company"] = "{{ company|safe }}";
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
load_contribution_summary(uri_options);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script id="contribution_template" type="text/x-jquery-tmpl">
|
||||||
|
{% raw %}
|
||||||
|
<div>Total commits: <b>${commit_count}</b></div>
|
||||||
|
<div>Total LOC: <b>${loc}</b></div>
|
||||||
|
<div>Review stat (-2, -1, +1, +2, A): <b>${marks["-2"]}, ${marks["-1"]}, ${marks["1"]}, ${marks["2"]}, ${marks["A"]}</b></div>
|
||||||
|
<div>Draft Blueprints: <b>${drafted_blueprint_count}</b></div>
|
||||||
|
<div>Completed Blueprints: <b>${completed_blueprint_count}</b></div>
|
||||||
|
<div>Emails: <b>${email_count}</b></div>
|
||||||
|
{% endraw %}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h2>Contribution Summary</h2>
|
||||||
|
<div id="contribution_container"></div>
|
||||||
|
|
||||||
|
{%- endmacro %}
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% import '_macros/activity_log.html' as activity_log %}
|
{% import '_macros/activity_log.html' as activity_log %}
|
||||||
|
{% import '_macros/contribution_summary.html' as contribution_summary %}
|
||||||
|
|
||||||
{% set show_company_breakdown = (not company) and (not user_id) %}
|
{% set show_company_breakdown = (not company) and (not user_id) %}
|
||||||
{% set show_engineer_breakdown = (not user_id) %}
|
{% set show_engineer_breakdown = (not user_id) %}
|
||||||
@ -10,11 +11,24 @@
|
|||||||
{% set show_activity = (show_user_activity) or (show_module_activity) %}
|
{% set show_activity = (show_user_activity) or (show_module_activity) %}
|
||||||
{% set show_user_contribution = (user_id) or (company) %}
|
{% set show_user_contribution = (user_id) or (company) %}
|
||||||
{% set show_module_contribution = (module) and (not user_id) %}
|
{% set show_module_contribution = (module) and (not user_id) %}
|
||||||
{% set show_contribution = (show_user_contribution) or (show_module_contribution) %}
|
|
||||||
{% set show_user_profile = (user_id) %}
|
{% set show_user_profile = (user_id) %}
|
||||||
{% set show_top_mentors_options = (metric == 'tm_marks') %}
|
{% set show_top_mentors_options = (metric == 'tm_marks') %}
|
||||||
{% set show_review_ratio = (metric in ['marks', 'tm_marks']) %}
|
{% set show_review_ratio = (metric in ['marks', 'tm_marks']) %}
|
||||||
|
|
||||||
|
{% macro show_report_links(module=None, company=None, user_id=None) -%}
|
||||||
|
{% if module %}
|
||||||
|
<div><b><a href="/report/reviews/{{ module }}/open" target="_blank">Show open reviews for {{ module }}↗</a></b></div>
|
||||||
|
<div><b><a href="/report/contribution/{{ module }}/30" target="_blank">Contribution for the last 30 days in {{ module }}↗</a></b></div>
|
||||||
|
<div><b><a href="/report/contribution/{{ module }}/90" target="_blank">Contribution for the last 90 days in {{ module }}↗</a></b></div>
|
||||||
|
{% endif %}
|
||||||
|
{% if company %}
|
||||||
|
<div><b><a href="/report/companies/{{ company }}" target="_blank">Show activity report for {{ company_original }}↗</a></b></div>
|
||||||
|
{% endif %}
|
||||||
|
{% if user_id %}
|
||||||
|
<div><b><a href="/report/users/{{ user_id }}" target="_blank">Show activity report for {{ user_id }}↗</a></b></div>
|
||||||
|
{% endif %}
|
||||||
|
{%- endmacro %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
@ -51,17 +65,6 @@
|
|||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if show_contribution %}
|
|
||||||
$(document).ready(function () {
|
|
||||||
$.ajax({
|
|
||||||
url: make_uri("/api/1.0/contribution"),
|
|
||||||
dataType: "json",
|
|
||||||
success: function (data) {
|
|
||||||
$("#contribution_template").tmpl(data["contribution"]).appendTo("#contribution_container");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
{% endif %}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{# Templates #}
|
{# Templates #}
|
||||||
@ -83,29 +86,6 @@
|
|||||||
{% endraw %}
|
{% endraw %}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script id="contribution_template" type="text/x-jquery-tmpl">
|
|
||||||
{% raw %}
|
|
||||||
<h2>Contribution Summary</h2>
|
|
||||||
<div>Total commits: <b>${commit_count}</b></div>
|
|
||||||
<div>Total LOC: <b>${loc}</b></div>
|
|
||||||
<div>Review stat (-2, -1, +1, +2, A): <b>${marks["-2"]}, ${marks["-1"]}, ${marks["1"]}, ${marks["2"]}, ${marks["A"]}</b></div>
|
|
||||||
{% endraw %}
|
|
||||||
<div>Draft Blueprints: <b>${drafted_blueprint_count}</b></div>
|
|
||||||
<div>Completed Blueprints: <b>${completed_blueprint_count}</b></div>
|
|
||||||
<div>Emails: <b>${email_count}</b></div>
|
|
||||||
{% if module %}
|
|
||||||
<div><b><a href="/report/reviews/{{ module }}/open" target="_blank">Show open reviews for {{ module }}↗</a></b></div>
|
|
||||||
<div><b><a href="/report/contribution/{{ module }}/30" target="_blank">Contribution for the last 30 days in {{ module }}↗</a></b></div>
|
|
||||||
<div><b><a href="/report/contribution/{{ module }}/90" target="_blank">Contribution for the last 90 days in {{ module }}↗</a></b></div>
|
|
||||||
{% endif %}
|
|
||||||
{% if company %}
|
|
||||||
<div><b><a href="/report/companies/{{ company }}" target="_blank">Show activity report for {{ company_original }}↗</a></b></div>
|
|
||||||
{% endif %}
|
|
||||||
{% if user_id %}
|
|
||||||
<div><b><a href="/report/users/{{ user_id }}" target="_blank">Show activity report for {{ user_id }}↗</a></b></div>
|
|
||||||
{% endif %}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block report_options %}
|
{% block report_options %}
|
||||||
@ -202,7 +182,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if show_module_contribution %}
|
{% if show_module_contribution %}
|
||||||
<div id="contribution_container"></div>
|
{{ contribution_summary.show_contribution_summary(show_all=False) }}
|
||||||
|
{{ show_report_links(module, company, user_id) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -258,7 +239,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if show_user_contribution %}
|
{% if show_user_contribution %}
|
||||||
<div id="contribution_container"></div>
|
{{ contribution_summary.show_contribution_summary(show_all=False) }}
|
||||||
|
{{ show_report_links(module, company, user_id) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if show_module_activity %}
|
{% if show_module_activity %}
|
||||||
|
@ -40,21 +40,6 @@
|
|||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% macro show_contribution_summary(contribution) -%}
|
|
||||||
|
|
||||||
<h2>Contribution summary</h2>
|
|
||||||
<ul>
|
|
||||||
<li>Total commits: {{ contribution.commit_count }}</li>
|
|
||||||
<li>Total LOC: {{ contribution.loc }}</li>
|
|
||||||
<li>Review stat (-2, -1, +1, +2): {{ contribution.marks[-2] }}, {{ contribution.marks[-1] }},
|
|
||||||
{{ contribution.marks[1] }}, {{ contribution.marks[2] }}</li>
|
|
||||||
<li>Draft Blueprints: {{ contribution.drafted_blueprint_count }}</li>
|
|
||||||
<li>Completed Blueprints: {{ contribution.completed_blueprint_count }}</li>
|
|
||||||
<li>Emails: {{ contribution.email_count }}</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{%- endmacro %}
|
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<div style="margin: 2em;">
|
<div style="margin: 2em;">
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "reports/base_report.html" %}
|
{% extends "reports/base_report.html" %}
|
||||||
{% import '_macros/activity_log.html' as activity_log %}
|
{% import '_macros/activity_log.html' as activity_log %}
|
||||||
|
{% import '_macros/contribution_summary.html' as contribution_summary %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ company_name }} activity in OpenStack
|
{{ company_name }} activity in OpenStack
|
||||||
@ -16,7 +17,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ company_name }} activity report</h1>
|
<h1>{{ company_name }} activity report</h1>
|
||||||
|
|
||||||
{{ show_contribution_summary(contribution) }}
|
{{ contribution_summary.show_contribution_summary(company=company_name) }}
|
||||||
|
|
||||||
<div id="punch_card" style="width: 100%; height: 350px;"></div>
|
<div id="punch_card" style="width: 100%; height: 350px;"></div>
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "reports/base_report.html" %}
|
{% extends "reports/base_report.html" %}
|
||||||
{% import '_macros/activity_log.html' as activity_log %}
|
{% import '_macros/activity_log.html' as activity_log %}
|
||||||
|
{% import '_macros/contribution_summary.html' as contribution_summary %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ user.user_name }} activity in OpenStack
|
{{ user.user_name }} activity in OpenStack
|
||||||
@ -30,7 +31,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{{ show_contribution_summary(contribution) }}
|
{{ contribution_summary.show_contribution_summary(user_id=user.user_id) }}
|
||||||
|
|
||||||
<div id="punch_card" style="width: 100%; height: 350px;"></div>
|
<div id="punch_card" style="width: 100%; height: 350px;"></div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user