From f539bc01dd53e069da305c3e2b08f7872d67f3e5 Mon Sep 17 00:00:00 2001 From: Andrii Ostapenko Date: Wed, 26 Jun 2019 11:09:01 -0500 Subject: [PATCH] Update release for commit after date update Updates commit release after commit date is updated with change merge date in case if commit is not a part of release_index. Change-Id: I94db5fb02ddede17b3958150fdbcffc52367ea21 --- stackalytics/processor/record_processor.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/stackalytics/processor/record_processor.py b/stackalytics/processor/record_processor.py index 682785f95..d9b4382c0 100644 --- a/stackalytics/processor/record_processor.py +++ b/stackalytics/processor/record_processor.py @@ -491,9 +491,10 @@ class RecordProcessor(object): yield translation - def _renew_record_date(self, record): + def _renew_record_date(self, record, force_update_release=False): record['week'] = utils.timestamp_to_week(record['date']) - if ('release' not in record) or (not record['release']): + if (force_update_release or ('release' not in record) or + (not record['release'])): record['release'] = self._get_release(record['date']) def process(self, record_iterator): @@ -549,7 +550,7 @@ class RecordProcessor(object): yield record_handler - def _update_commits_with_merge_date(self): + def _update_commits_with_merge_date(self, release_index): LOG.info('Update commits with merge date') change_id_to_date = {} @@ -574,7 +575,11 @@ class RecordProcessor(object): old_date = record['date'] if old_date != change_id_to_date[change_id]: record['date'] = change_id_to_date[change_id] - self._renew_record_date(record) + force_update_release = ( + record['primary_key'] not in release_index + ) + self._renew_record_date(record, + force_update_release) LOG.debug('Date %(date)s has changed in record ' '%(record)s', {'date': old_date, 'record': record}) @@ -786,7 +791,8 @@ class RecordProcessor(object): def post_processing(self, release_index): processors = [ self._update_records_with_user_info, - self._update_commits_with_merge_date, + functools.partial(self._update_commits_with_merge_date, + release_index), functools.partial(self._update_records_with_releases, release_index), self._update_commits_with_module_alias,