Expect new types of approval records from Gerrit

In Gerrit 2.8 approval types were changed from:
 CRVW became 'Code-Review'
 VRIF became 'Verifyied'
 APRV became 'Approved'

Note: Upgrade-Impact on reviews

Change-Id: I6a2cd64ace41cf1e65d4777aa249f286fe848a8a
This commit is contained in:
Ilya Shakhat
2014-04-30 15:58:51 +04:00
parent 15800b759e
commit a68a104695
7 changed files with 18 additions and 21 deletions

View File

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

View File

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

View File

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

View File

@@ -322,10 +322,6 @@ class RecordProcessor(object):
mark['review_id'] = review['id'] mark['review_id'] = review['id']
mark['patch'] = int(patch['number']) 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) self._update_record_and_user(mark)
return mark return mark
@@ -353,7 +349,7 @@ class RecordProcessor(object):
continue # not reviewed by anyone continue # not reviewed by anyone
for approval in patch['approvals']: for approval in patch['approvals']:
if approval['type'] not in ('CRVW', 'APRV'): if approval['type'] not in ('Code-Review', 'Approved'):
continue # keep only Code-Review and Approved continue # keep only Code-Review and Approved
if ('email' not in approval['by'] or if ('email' not in approval['by'] or
'username' not in approval['by']): 'username' not in approval['by']):
@@ -681,7 +677,8 @@ class RecordProcessor(object):
lambda: {'patch_number': 0, 'marks': []}) lambda: {'patch_number': 0, 'marks': []})
for record in self.runtime_storage_inst.get_all_records(): for record in self.runtime_storage_inst.get_all_records():
if record['record_type'] == 'mark' and record['type'] == 'CRVW': if ((record['record_type'] == 'mark') and
(record['type'] == 'Code-Review')):
review_id = record['review_id'] review_id = record['review_id']
patch_number = record['patch'] patch_number = record['patch']

View File

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

View File

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

View File

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