Implemented new metric for newcommers reviews
Change-Id: I797dfe40e966daf510a8c91ff2c912e29692cc33
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
{% set show_company_breakdown = (not company) and (not user_id) %}
|
||||
{% set show_engineer_breakdown = ((company) or (module)) and (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) %}
|
||||
{% set show_module_activity = (module) and (not user_id) %}
|
||||
@@ -22,6 +23,9 @@
|
||||
{% if show_engineer_breakdown %}
|
||||
renderTableAndChart("/api/1.0/stats/engineers", "engineer_container", "engineer_table", "engineer_chart", "user_id", {company: "{{ company|encode }}" });
|
||||
{% endif %}
|
||||
{% if show_bp_breakdown %}
|
||||
renderTableAndChart("/api/1.0/stats/bpd", "bp_container", "bp_table", "bp_chart", "bpd", {module: "{{ module|encode }}" });
|
||||
{% endif %}
|
||||
{% if show_module_breakdown %}
|
||||
renderTableAndChart("/api/1.0/stats/modules", "module_container", "module_table", "module_chart", "module");
|
||||
{% endif %}
|
||||
@@ -108,7 +112,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 submitted by {%html parent_author_link %}</div>
|
||||
<div>Patch #${review_attempt} 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>
|
||||
@@ -210,7 +214,7 @@
|
||||
<th>#</th>
|
||||
<th>Engineer</th>
|
||||
<th>{{ metric_label }}</th>
|
||||
{% if metric == 'marks' %}
|
||||
{% if metric in ['marks', 'nc_marks'] %}
|
||||
<th>-2|-1|+1|+2 (+/- ratio)</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
@@ -222,6 +226,27 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_bp_breakdown %}
|
||||
<div id="bp_container">
|
||||
<h2>Mention # by blueprint</h2>
|
||||
|
||||
<div id="bp_chart" style="width: 100%; height: 350px;"></div>
|
||||
|
||||
<table id="bp_table" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Blueprint</th>
|
||||
<th>Mention #</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if show_user_profile %}
|
||||
<div id="user_profile_container" style="margin-bottom: 2em;"></div>
|
||||
{% endif %}
|
||||
|
||||
@@ -47,6 +47,7 @@ METRIC_LABELS = {
|
||||
'loc': 'Lines of code',
|
||||
'commits': 'Commits',
|
||||
'marks': 'Reviews',
|
||||
'nc_marks': 'Newcomers Reviews',
|
||||
'emails': 'Emails',
|
||||
'bpd': 'Drafted Blueprints',
|
||||
'bpc': 'Completed Blueprints',
|
||||
@@ -56,6 +57,7 @@ METRIC_TO_RECORD_TYPE = {
|
||||
'loc': 'commit',
|
||||
'commits': 'commit',
|
||||
'marks': 'mark',
|
||||
'nc_marks': 'mark',
|
||||
'emails': 'email',
|
||||
'bpd': 'bpd',
|
||||
'bpc': 'bpc',
|
||||
@@ -347,6 +349,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
|
||||
|
||||
kwargs['records'] = memory_storage.get_records(record_ids)
|
||||
return f(*args, **kwargs)
|
||||
|
||||
@@ -404,6 +416,7 @@ def aggregate_filter():
|
||||
'commits': (incremental_filter, None),
|
||||
'loc': (loc_filter, None),
|
||||
'marks': (mark_filter, mark_finalize),
|
||||
'nc_marks': (mark_filter, mark_finalize),
|
||||
'emails': (incremental_filter, None),
|
||||
'bpd': (incremental_filter, None),
|
||||
'bpc': (incremental_filter, None),
|
||||
@@ -646,6 +659,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['subject'] = parent['subject']
|
||||
review['url'] = parent['url']
|
||||
review['parent_author_link'] = make_link(
|
||||
@@ -782,6 +796,39 @@ def get_module(module):
|
||||
flask.abort(404)
|
||||
|
||||
|
||||
@app.route('/api/1.0/stats/bpd/<module>')
|
||||
@jsonify('stats')
|
||||
@exception_handler()
|
||||
def get_bpd(module):
|
||||
memory_storage_inst = get_vault()['memory_storage']
|
||||
|
||||
module = module.lower()
|
||||
record_ids = (
|
||||
set(memory_storage_inst.get_record_ids_by_type('bpd')) &
|
||||
set(memory_storage_inst.get_record_ids_by_modules([module])))
|
||||
|
||||
# param = get_parameter(kwargs, 'release', 'releases', use_default)
|
||||
# if param:
|
||||
# if 'all' not in param:
|
||||
# record_ids &= (
|
||||
# memory_storage.get_record_ids_by_releases(
|
||||
# c.lower() for c in param))
|
||||
|
||||
result = []
|
||||
for record in memory_storage_inst.get_records(record_ids):
|
||||
result.append({
|
||||
'date': record['date'],
|
||||
'lifecycle_status': record['lifecycle_status'],
|
||||
'metric': record['mention_count'],
|
||||
'id': record['name'],
|
||||
'name': record['name'],
|
||||
})
|
||||
|
||||
result.sort(key=lambda x: x['metric'])
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@app.route('/api/1.0/users')
|
||||
@jsonify('users')
|
||||
@exception_handler()
|
||||
|
||||
@@ -372,6 +372,7 @@ class RecordProcessor(object):
|
||||
self.runtime_storage_inst.set_by_key('users', self.users_index)
|
||||
|
||||
def _get_records_for_users_to_update(self):
|
||||
users_reviews = {}
|
||||
valid_blueprints = {}
|
||||
mentioned_blueprints = {}
|
||||
for record in self.runtime_storage_inst.get_all_records():
|
||||
@@ -392,6 +393,14 @@ class RecordProcessor(object):
|
||||
'date': record['date']
|
||||
}
|
||||
|
||||
if record['record_type'] == 'review':
|
||||
launchpad_id = record['launchpad_id']
|
||||
review = {'date': record['date'], 'id': record['id']}
|
||||
if launchpad_id in users_reviews:
|
||||
users_reviews[launchpad_id].append(review)
|
||||
else:
|
||||
users_reviews[launchpad_id] = [review]
|
||||
|
||||
for bp in valid_blueprints.keys():
|
||||
if bp in mentioned_blueprints:
|
||||
valid_blueprints[bp]['count'] = (
|
||||
@@ -399,6 +408,15 @@ class RecordProcessor(object):
|
||||
valid_blueprints[bp]['date'] = (
|
||||
mentioned_blueprints[bp]['date'])
|
||||
|
||||
reviews_index = {}
|
||||
for launchpad_id, reviews in users_reviews.iteritems():
|
||||
reviews.sort(key=lambda x: x['date'])
|
||||
review_attempt = 0
|
||||
for review in reviews:
|
||||
review_attempt += 1
|
||||
review['review_attempt'] = review_attempt
|
||||
reviews_index[review['id']] = review
|
||||
|
||||
for record in self.runtime_storage_inst.get_all_records():
|
||||
|
||||
need_update = False
|
||||
@@ -433,6 +451,12 @@ class RecordProcessor(object):
|
||||
record['primary_key'], bp['count'], bp['date'])
|
||||
need_update = True
|
||||
|
||||
if record['record_type'] == 'review':
|
||||
review = reviews_index[record['id']]
|
||||
if record.get('review_attempt') != review['review_attempt']:
|
||||
record['review_attempt'] = review['review_attempt']
|
||||
need_update = True
|
||||
|
||||
if need_update:
|
||||
yield record
|
||||
|
||||
|
||||
Reference in New Issue
Block a user