diff --git a/dashboard/decorators.py b/dashboard/decorators.py index 5fba4fb38..daff6a225 100644 --- a/dashboard/decorators.py +++ b/dashboard/decorators.py @@ -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'] diff --git a/dashboard/helpers.py b/dashboard/helpers.py index d387d326e..a9d4012ba 100644 --- a/dashboard/helpers.py +++ b/dashboard/helpers.py @@ -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 diff --git a/dashboard/reports.py b/dashboard/reports.py index 733d651c4..99890a930 100644 --- a/dashboard/reports.py +++ b/dashboard/reports.py @@ -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': diff --git a/stackalytics/processor/record_processor.py b/stackalytics/processor/record_processor.py index 9a5df7ed9..8639a62da 100644 --- a/stackalytics/processor/record_processor.py +++ b/stackalytics/processor/record_processor.py @@ -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'] diff --git a/tests/api/test_api.py b/tests/api/test_api.py index fc22e6d58..7c598f614 100644 --- a/tests/api/test_api.py +++ b/tests/api/test_api.py @@ -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 diff --git a/tests/api/test_stats.py b/tests/api/test_stats.py index e02c0a157..a753e366e 100644 --- a/tests/api/test_stats.py +++ b/tests/api/test_stats.py @@ -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'], diff --git a/tests/unit/test_record_processor.py b/tests/unit/test_record_processor.py index 210dac403..a61140d4f 100644 --- a/tests/unit/test_record_processor.py +++ b/tests/unit/test_record_processor.py @@ -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',