Implementation of top mentors report

* Renamed report from New-comers to Top Mentors
* Made review threshold configurable
* Renamed field that holds review number

Implements blueprint bp-popularity

Change-Id: If9ca4597e2a1e3225cd80be92a9f3c3f63a1654c
This commit is contained in:
Ilya Shakhat 2013-10-14 16:42:04 +04:00
parent e9df455a52
commit bc3d2c6df1
5 changed files with 70 additions and 22 deletions

View File

@ -79,7 +79,7 @@ div.drops {
margin-top: 10px;
}
div.drops label {
div.drop label {
color: #909cb5;
}

View File

@ -270,6 +270,10 @@
<div id="timeline" style="width: 100%; height: 120px; margin-top: 15px;"></div>
</div>
<div>
{% block report_options %}{% endblock %}
</div>
<table style="width: 100%" cellspacing="0">
<tr>
<td style="width: 50%; vertical-align: top;">

View File

@ -1,7 +1,7 @@
{% extends "layout.html" %}
{% set show_company_breakdown = (not company) and (not user_id) %}
{% set show_engineer_breakdown = ((company) or (module)) and (not user_id) %}
{% set show_engineer_breakdown = (not user_id) %}
{% set show_bp_breakdown = (module) and (not user_id) and (metric == 'bpd!') %}
{% set show_module_breakdown = (not module) %}
{% set show_user_activity = (user_id) %}
@ -11,6 +11,7 @@
{% 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_top_mentors_options = (metric == 'tm_marks') %}
{% block scripts %}
<script type="text/javascript">
@ -112,7 +113,7 @@
<div><span style="color: green">+<span>${lines_added}</span></span>
<span style="color: blue">- <span>${lines_deleted}</span></span></div>
{%elif record_type == "mark" %}
<div>Patch #${review_attempt} submitted by {%html parent_author_link %}</div>
<div>Review #${review_number} submitted by {%html parent_author_link %}</div>
<div style='font-weight: bold;'>${subject}</div>
<div>Change Id: <a href="${url}">${review_id}</a></div>
<div style="color: {%if value > 0 %} green {%else%} blue {%/if%}">${description}: <span class="review_mark">${value}</span></div>
@ -179,6 +180,45 @@
{% endblock %}
{% block report_options %}
{% if show_top_mentors_options %}
<script type='text/javascript'>
$(document).ready(function () {
$('#review_nth').val('{{ review_nth }}');
$("#review_nth").select2();
});
function make_options() {
var options = make_std_options();
options['review_nth'] = $('#review_nth').val();
return options;
}
function reload() {
window.location.search = $.map(make_options(),function (val, index) {
return index + "=" + val;
}).join("&")
}
$(document).on('change', '#review_nth', function (evt) {
reload();
});
</script>
<div class="drop" style="margin-top: 1em;">
<label for="review_nth">Review #</label>
<select id="review_nth" name="review_nth"
style="min-width: 140px;"
data-placeholder="Select review #">
<option></option>
{% set review_number_options = [1, 2, 3, 4, 5, 10, 15] %}
{% for option in review_number_options %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{% endblock %}
{% block left_frame %}
{% if show_company_breakdown %}
@ -214,7 +254,7 @@
<th>#</th>
<th>Engineer</th>
<th>{{ metric_label }}</th>
{% if metric in ['marks', 'nc_marks'] %}
{% if metric in ['marks', 'tm_marks'] %}
<th>-2|-1|+1|+2 (+/- ratio)</th>
{% endif %}
</tr>

View File

@ -41,13 +41,14 @@ DEFAULTS = {
'metric': 'commits',
'release': 'havana',
'project_type': 'openstack',
'review_nth': 5,
}
METRIC_LABELS = {
'loc': 'Lines of code',
'commits': 'Commits',
'marks': 'Reviews',
'nc_marks': 'Newcomers Reviews',
'tm_marks': 'Top Mentors',
'emails': 'Emails',
'bpd': 'Drafted Blueprints',
'bpc': 'Completed Blueprints',
@ -57,7 +58,7 @@ METRIC_TO_RECORD_TYPE = {
'loc': 'commit',
'commits': 'commit',
'marks': 'mark',
'nc_marks': 'mark',
'tm_marks': 'mark',
'emails': 'email',
'bpd': 'bpd',
'bpc': 'bpc',
@ -349,15 +350,16 @@ def record_filter(ignore=None, use_default=True):
record_ids &= memory_storage.get_record_ids_by_type(
METRIC_TO_RECORD_TYPE[metric])
if metric == 'nc_marks':
filtered_ids = []
for record in memory_storage.get_records(record_ids):
parent = memory_storage.get_record_by_primary_key(
record['review_id'])
if (parent and ('review_attempt' in parent)
and (parent['review_attempt'] <= 5)):
filtered_ids.append(record['record_id'])
record_ids = filtered_ids
if 'tm_marks' in metrics:
filtered_ids = []
review_nth = int(get_parameter(kwargs, 'review_nth')[0])
for record in memory_storage.get_records(record_ids):
parent = memory_storage.get_record_by_primary_key(
record['review_id'])
if (parent and ('review_number' in parent) and
(parent['review_number'] <= review_nth)):
filtered_ids.append(record['record_id'])
record_ids = filtered_ids
kwargs['records'] = memory_storage.get_records(record_ids)
return f(*args, **kwargs)
@ -416,7 +418,7 @@ def aggregate_filter():
'commits': (incremental_filter, None),
'loc': (loc_filter, None),
'marks': (mark_filter, mark_finalize),
'nc_marks': (mark_filter, mark_finalize),
'tm_marks': (mark_filter, mark_finalize),
'emails': (incremental_filter, None),
'bpd': (incremental_filter, None),
'bpc': (incremental_filter, None),
@ -509,6 +511,8 @@ def templated(template=None, return_code=200):
else:
release = releases[release]['release_name']
ctx['release'] = (release or get_default('release')).lower()
ctx['review_nth'] = (flask.request.args.get('review_nth') or
get_default('review_nth'))
ctx['project_type_options'] = get_project_type_options()
ctx['release_options'] = get_release_options()
@ -659,7 +663,7 @@ def get_activity_json(records):
parent = memory_storage_inst.get_record_by_primary_key(
review['review_id'])
if parent:
review['review_attempt'] = parent.get('review_attempt')
review['review_number'] = parent.get('review_number')
review['subject'] = parent['subject']
review['url'] = parent['url']
review['parent_author_link'] = make_link(

View File

@ -411,10 +411,10 @@ class RecordProcessor(object):
reviews_index = {}
for launchpad_id, reviews in users_reviews.iteritems():
reviews.sort(key=lambda x: x['date'])
review_attempt = 0
review_number = 0
for review in reviews:
review_attempt += 1
review['review_attempt'] = review_attempt
review_number += 1
review['review_number'] = review_number
reviews_index[review['id']] = review
for record in self.runtime_storage_inst.get_all_records():
@ -453,8 +453,8 @@ class RecordProcessor(object):
if record['record_type'] == 'review':
review = reviews_index[record['id']]
if record.get('review_attempt') != review['review_attempt']:
record['review_attempt'] = review['review_attempt']
if record.get('review_number') != review['review_number']:
record['review_number'] = review['review_number']
need_update = True
if need_update: