Ignore self-reviews in stats

Self-reviews are +1 and +2 votes that author sets for own patch set.
They are ignored in statistics and marked as Self- in activity log.

Closes bug 1439182

Change-Id: I72c0d65d0850f09daa9f89a11ad324d74c020e2f
This commit is contained in:
Ilya Shakhat 2015-04-08 19:53:41 +03:00
parent 5a9aac2e07
commit a0d56ba934
5 changed files with 43 additions and 13 deletions

View File

@ -252,13 +252,14 @@ def loc_filter(result, record, param_id, context):
def mark_filter(result, record, param_id, context):
result_by_param = result[getattr(record, param_id)]
value = record.value
value = 0
record_type = record.type
if record_type == 'Code-Review':
result_by_param['metric'] += 1
value = record.value
elif record.type == 'Workflow':
if value == 1:
if record.value == 1:
value = 'A'
else:
value = 'WIP'

View File

@ -49,11 +49,11 @@ def _extend_record_common_fields(record):
_extend_author_fields(coauthor)
def _extend_by_parent_info(record, parent):
def _extend_by_parent_info(record, parent, prefix='parent_'):
parent = vault.extend_record(parent)
_extend_record_common_fields(parent)
for k, v in six.iteritems(parent):
record['parent_' + k] = v
record[prefix + k] = v
def extend_record(record):
@ -68,16 +68,19 @@ def extend_record(record):
if record['commit_date']:
record['commit_date_str'] = format_datetime(record['commit_date'])
elif record['record_type'] == 'mark':
parent = vault.get_memory_storage().get_record_by_primary_key(
review = vault.get_memory_storage().get_record_by_primary_key(
record['review_id'])
if not parent:
patch = vault.get_memory_storage().get_record_by_primary_key(
utils.get_patch_id(record['review_id'], record['patch']))
if not review or not patch:
return None
_extend_by_parent_info(record, parent)
_extend_by_parent_info(record, review, 'parent_')
_extend_by_parent_info(record, patch, 'patch_')
elif record['record_type'] == 'patch':
parent = vault.get_memory_storage().get_record_by_primary_key(
review = vault.get_memory_storage().get_record_by_primary_key(
record['review_id'])
_extend_by_parent_info(record, parent)
_extend_by_parent_info(record, review, 'parent_')
elif record['record_type'] == 'email':
record['email_link'] = record.get('email_link') or ''
record['blueprint_links'] = []
@ -182,12 +185,14 @@ def get_contribution_summary(records):
commit_count += 1
loc += record.loc
elif record_type == 'mark':
value = record.value
value = 0
if record.type == 'Workflow':
if value == 1:
if record.value == 1:
value = 'A'
else:
value = 'WIP'
elif record.type == 'Code-Review':
value = record.value
marks[value] += 1
elif record_type == 'email':
email_count += 1

View File

@ -95,11 +95,16 @@ show_record_type=True, show_user_gravatar=True, gravatar_size=32, show_all=True)
<span style="color: blue">- <span>${lines_deleted}</span></span></div>
{%elif record_type == "mark" %}
<div class="header">Review &ldquo;${parent_subject}&rdquo;</div>
<div>Submitted by: {%html parent_author_link %} ({%html parent_company_link %}) (#${parent_review_number})</div>
<div>Review submitted by: {%html parent_author_link %} ({%html parent_company_link %})</div>
{%if patch_author_link != parent_author_link %}
<div>Patch submitted by: {%html patch_author_link %} ({%html patch_company_link %})</div>
{%/if%}
<div>Change Id: <a href="${parent_url}" target="_blank">${review_id}</a></div>
<div style="color: {%if value > 0 %} green {%else%} blue {%/if%}">
{%if (type == "Workflow" && value == 1) %}
Approved
{%elif (type == "Self-Workflow" && value == 1) %}
Self-Approved
{%elif (type == "Workflow" && value == -1) %}
Work in progress
{%else%}

View File

@ -831,6 +831,23 @@ class RecordProcessor(object):
}]
user_processor.store_user(self.runtime_storage_inst, user)
def _update_self_made_marks(self):
LOG.debug('Update self-made marks')
patch_id_to_user_id = {}
for record in self.runtime_storage_inst.get_all_records():
if record['record_type'] == 'patch':
patch_id_to_user_id[record['primary_key']] = record['user_id']
for record in self.runtime_storage_inst.get_all_records():
if record['record_type'] != 'mark':
continue
patch_id = utils.get_patch_id(record['review_id'], record['patch'])
if record['user_id'] == patch_id_to_user_id.get(patch_id):
if record['type'].find('Self-') < 0:
record['type'] = 'Self-%s' % record['type']
yield record
def post_processing(self, release_index):
self.runtime_storage_inst.set_records(
self._update_records_with_user_info())
@ -855,3 +872,5 @@ class RecordProcessor(object):
self.runtime_storage_inst.set_records(
self._update_members_company_name())
self.runtime_storage_inst.set_records(self._update_self_made_marks())

View File

@ -219,7 +219,7 @@ def get_bug_id(module, bug_id):
def get_patch_id(review_id, patch_number):
return review_id + ':' + patch_number
return '%s:%s' % (review_id, patch_number)
def add_index(sequence, start=1, item_filter=lambda x: True):