From 43201e79a93a0f3757a6bf22f7f6767f52776ade Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Fri, 16 Oct 2015 13:33:40 +0300 Subject: [PATCH] Optimize calclulation of self-made marks Previously self-made marks were re-calculated every time on post-processing. This made sense in order to not require re-read of all reviews. Now, change the processing to time of reading. Change-Id: I9e96f329b1b4474ea5602d3b0903b64c63e6c530 --- stackalytics/processor/record_processor.py | 23 ++++------------------ 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/stackalytics/processor/record_processor.py b/stackalytics/processor/record_processor.py index ffe9c173e..9b9544a18 100644 --- a/stackalytics/processor/record_processor.py +++ b/stackalytics/processor/record_processor.py @@ -396,6 +396,10 @@ class RecordProcessor(object): mark['review_id'] = review['id'] mark['patch'] = int(patch['number']) + if reviewer['username'] == patch['uploader'].get('username'): + # reviewer is the same as author of the patch + mark['type'] = 'Self-%s' % mark['type'] + self._update_record_and_user(mark) return mark @@ -818,23 +822,6 @@ class RecordProcessor(object): }] user_processor.store_user(self.runtime_storage_inst, user) - def _update_self_made_marks(self): - LOG.info('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'][:5] != 'Self-': - 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()) @@ -856,5 +843,3 @@ 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())