Update commit records with module aliases

When repos are renamed, commit records with the old name remain and are
not counted for the new repo name.
During post-process, rename the module name of all commits with the old
name, to be the new name.

Change-Id: I8684c5a1949ea916768bce9441d011325d079ad4
Closes-Bug: #1674092
This commit is contained in:
Yuval Brik
2017-03-20 17:52:07 +02:00
parent c2946165f8
commit 57de5f7ba3
2 changed files with 51 additions and 0 deletions

View File

@@ -1326,6 +1326,7 @@ class TestRecordProcessor(testtools.TestCase):
'date': 1234567890,
'lines_added': 25,
'lines_deleted': 9,
'module': u'stackalytics',
'release_name': 'havana'},
{'record_type': 'review',
'id': 'I104573',
@@ -1343,6 +1344,39 @@ class TestRecordProcessor(testtools.TestCase):
commit = runtime_storage_inst.get_by_primary_key('de7e8f2')
self.assertEqual(1385490000, commit['date'])
def test_commit_module_alias(self):
record_processor_inst = self.make_record_processor()
runtime_storage_inst = record_processor_inst.runtime_storage_inst
with mock.patch('stackalytics.processor.utils.load_repos') as patch:
patch.return_value = [{'module': 'sahara', 'aliases': ['savanna']}]
runtime_storage_inst.set_records(record_processor_inst.process([
{'record_type': 'commit',
'commit_id': 'de7e8f2',
'change_id': ['I104573'],
'author_name': 'John Doe',
'author_email': 'john_doe@gmail.com',
'date': 1234567890,
'lines_added': 25,
'lines_deleted': 9,
'module': u'savanna',
'release_name': 'havana'},
{'record_type': 'review',
'id': 'I104573',
'subject': 'Fix AttributeError in Keypair._add_details()',
'owner': {'name': 'John Doe',
'email': 'john_doe@gmail.com',
'username': 'john_doe'},
'createdOn': 1385478465,
'lastUpdated': 1385490000,
'status': 'MERGED',
'module': 'nova', 'branch': 'master'},
]))
record_processor_inst.post_processing({})
commit = runtime_storage_inst.get_by_primary_key('de7e8f2')
self.assertEqual('sahara', commit['module'])
# update records
def _generate_record_commit(self):