Revert "Expect new types of approval records from Gerrit"

This reverts commit a68a1046953f844e76e284649077588f2595de58.

Type of all mark records is translated to old Gerrit format (CRVW, APRV)

Change-Id: Id92ba40d94aed78f13cdeee83b7dc2958eb1805c
This commit is contained in:
Ilya Shakhat 2014-05-01 21:19:53 +04:00
parent cc06cf6e98
commit 3764260997
7 changed files with 22 additions and 18 deletions

View File

@ -165,7 +165,7 @@ def loc_filter(result, record, param_id):
def mark_filter(result, record, param_id):
result_by_param = result[record[param_id]]
if record['type'] == 'Approved':
if record['type'] == 'APRV':
value = 'A'
else:
value = record['value']

View File

@ -151,7 +151,7 @@ def get_contribution_summary(records):
commit_count += 1
loc += record['loc']
elif record['record_type'] == 'mark':
if record['type'] == 'Approved':
if record['type'] == 'APRV':
marks['A'] += 1
else:
marks[record['value']] += 1

View File

@ -250,8 +250,8 @@ def get_single_plus_two_reviews_report(records):
if record['record_type'] != 'mark':
continue
if ((record['branch'] == 'master') and
(record['type'] == 'Code-Review') and (record['value'] == +2)):
if (record['branch'] == 'master' and record['type'] == 'CRVW' and
record['value'] == +2):
review_id = record['review_id']
review = memory_storage_inst.get_record_by_primary_key(review_id)
if review and review['status'] == 'MERGED':

View File

@ -322,6 +322,10 @@ class RecordProcessor(object):
mark['review_id'] = review['id']
mark['patch'] = int(patch['number'])
# map type from new Gerrit to old
mark['type'] = {'Approved': 'APRV', 'Code-Review': 'CRVW',
'Verified': 'VRIF'}.get(mark['type'], mark['type'])
self._update_record_and_user(mark)
return mark
@ -349,7 +353,8 @@ class RecordProcessor(object):
continue # not reviewed by anyone
for approval in patch['approvals']:
if approval['type'] not in ('Code-Review', 'Approved'):
if approval['type'] not in ('CRVW', 'APRV',
'Code-Review', 'Approved'):
continue # keep only Code-Review and Approved
if ('email' not in approval['by'] or
'username' not in approval['by']):
@ -677,8 +682,7 @@ class RecordProcessor(object):
lambda: {'patch_number': 0, 'marks': []})
for record in self.runtime_storage_inst.get_all_records():
if ((record['record_type'] == 'mark') and
(record['type'] == 'Code-Review')):
if record['record_type'] == 'mark' and record['type'] == 'CRVW':
review_id = record['review_id']
patch_number = record['patch']

View File

@ -122,11 +122,11 @@ def _generate_marks():
'launchpad_id': 'john_doe', 'week': 2294, 'user_id': 'john_doe',
'description': 'Approved', 'author_name': 'John Doe',
'author_email': 'john_doe@gmail.com',
'primary_key': str(uuid.uuid4()) + 'Approved',
'primary_key': str(uuid.uuid4()) + 'APRV',
'module': 'glance', 'patch': 2, 'record_type': 'mark',
'company_name': '*independent', 'branch': 'master',
'date': 1387860458, 'record_id': 37184, 'release': 'icehouse',
'value': 1, 'type': 'Approved',
'value': 1, 'type': 'APRV',
'review_id': str(uuid.uuid4())}
yield mark

View File

@ -138,7 +138,7 @@ class TestAPIStats(test_api.TestAPI):
review_id=['0123456789', '9876543210'],
module=['glance'],
value=[1],
type=['Code-Review'],
type=['CRVW'],
author_name=['John Doe'],
user_id=['john_doe']),
test_api.make_records(record_type=['mark'],

View File

@ -648,7 +648,7 @@ class TestRecordProcessor(testtools.TestCase):
'username': 'bsmith'},
'createdOn': 1385470730,
'approvals': [
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '1', 'grantedOn': 1385478464,
'by': {'name': 'John Doe', 'email': 'john_doe@ibm.com',
'username': 'john_doe'}}]}]}
@ -753,13 +753,13 @@ class TestRecordProcessor(testtools.TestCase):
'username': 'bsmith'},
'createdOn': timestamp,
'approvals': [
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '2', 'grantedOn': timestamp,
'by': {
'name': 'John Doe',
'email': 'john_doe@ibm.com',
'username': 'john_doe'}},
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '-1', 'grantedOn': timestamp - 1, # differ
'by': {
'name': 'Homer Simpson',
@ -936,13 +936,13 @@ class TestRecordProcessor(testtools.TestCase):
'username': 'bsmith'},
'createdOn': timestamp,
'approvals': [
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '2', 'grantedOn': timestamp - 1,
'by': {
'name': 'Homer Simpson',
'email': 'hsimpson@gmail.com',
'username': 'homer'}},
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '-2', 'grantedOn': timestamp,
'by': {
'name': 'John Doe',
@ -959,19 +959,19 @@ class TestRecordProcessor(testtools.TestCase):
'username': 'bsmith'},
'createdOn': timestamp + 1,
'approvals': [
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '1', 'grantedOn': timestamp + 2,
'by': {
'name': 'Homer Simpson',
'email': 'hsimpson@gmail.com',
'username': 'homer'}},
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '-1', 'grantedOn': timestamp + 3,
'by': {
'name': 'Bart Simpson',
'email': 'bsimpson@gmail.com',
'username': 'bart'}},
{'type': 'Code-Review', 'description': 'Code Review',
{'type': 'CRVW', 'description': 'Code Review',
'value': '2', 'grantedOn': timestamp + 4,
'by': {
'name': 'John Doe',