diff --git a/dashboard/helpers.py b/dashboard/helpers.py
index b48ea8121..e0d1e395c 100644
--- a/dashboard/helpers.py
+++ b/dashboard/helpers.py
@@ -52,6 +52,8 @@ def extend_record(record):
if 'correction_comment' not in record:
record['correction_comment'] = ''
record['message'] = make_commit_message(record)
+ if record['commit_date']:
+ record['commit_date_str'] = format_datetime(record['commit_date'])
elif record['record_type'] == 'mark':
parent = vault.get_memory_storage().get_record_by_primary_key(
record['review_id'])
diff --git a/dashboard/templates/_macros/activity_log.html b/dashboard/templates/_macros/activity_log.html
index 12576ddd7..c5782d17b 100644
--- a/dashboard/templates/_macros/activity_log.html
+++ b/dashboard/templates/_macros/activity_log.html
@@ -71,6 +71,9 @@
{%if record_type == "commit" %}
Commit “${subject}”
{%html message %}
+ {%if commit_date_str != "" %}
+ Commit date: ${commit_date_str}
+ {%/if%}
{%if correction_comment != "" %}
Commit corrected:
${correction_comment}
diff --git a/dashboard/templates/overview.html b/dashboard/templates/overview.html
index 027490243..9c314ec43 100644
--- a/dashboard/templates/overview.html
+++ b/dashboard/templates/overview.html
@@ -117,6 +117,9 @@
{%/if%}
${subject}
{%html message %}
+ {%if commit_date_str != "" %}
+ Commit date: ${commit_date_str}
+ {%/if%}
+${lines_added}
- ${lines_deleted}
{%elif record_type == "mark" %}
diff --git a/stackalytics/processor/record_processor.py b/stackalytics/processor/record_processor.py
index 383a5e099..fd72a41e3 100644
--- a/stackalytics/processor/record_processor.py
+++ b/stackalytics/processor/record_processor.py
@@ -226,6 +226,7 @@ class RecordProcessor(object):
record['primary_key'] = record['commit_id']
record['loc'] = record['lines_added'] + record['lines_deleted']
record['author_email'] = record['author_email'].lower()
+ record['commit_date'] = record['date']
self._update_record_and_user(record)
@@ -448,7 +449,26 @@ class RecordProcessor(object):
if need_update:
yield record
- def _update_records_with_blueprint_mention_info(self):
+ def _update_commits_with_merge_date(self):
+ change_id_to_date = {}
+ for record in self.runtime_storage_inst.get_all_records():
+ if (record['record_type'] == 'review' and
+ record.get('status') == 'MERGED'):
+ change_id_to_date[record['id']] = record['lastUpdated']
+
+ for record in self.runtime_storage_inst.get_all_records():
+ if record['record_type'] == 'commit':
+ change_id_list = record.get('change_id')
+ if change_id_list and len(change_id_list) == 1:
+ change_id = change_id_list[0]
+ if change_id in change_id_to_date:
+ 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)
+ yield record
+
+ def _update_blueprints_with_mention_info(self):
LOG.debug('Process blueprints and calculate mention info')
valid_blueprints = {}
@@ -505,7 +525,7 @@ class RecordProcessor(object):
if need_update:
yield record
- def _update_records_with_review_number(self):
+ def _update_reviews_with_sequence_number(self):
LOG.debug('Set review number in review records')
users_reviews = {}
@@ -556,7 +576,7 @@ class RecordProcessor(object):
if user['core'] != core_old:
utils.store_user(self.runtime_storage_inst, user)
- def _update_records_with_disagreement(self):
+ def _update_marks_with_disagreement(self):
LOG.debug('Process marks to find disagreements')
marks_per_patch = {}
@@ -602,13 +622,16 @@ class RecordProcessor(object):
self._update_records_with_user_info())
self.runtime_storage_inst.set_records(
- self._update_records_with_review_number())
+ self._update_reviews_with_sequence_number())
self.runtime_storage_inst.set_records(
- self._update_records_with_blueprint_mention_info())
+ self._update_blueprints_with_mention_info())
+
+ self.runtime_storage_inst.set_records(
+ self._update_commits_with_merge_date())
self._determine_core_contributors()
# disagreement calculation must go after determining core contributors
self.runtime_storage_inst.set_records(
- self._update_records_with_disagreement())
+ self._update_marks_with_disagreement())
diff --git a/tests/unit/test_record_processor.py b/tests/unit/test_record_processor.py
index 6a101062b..06ebfed3e 100644
--- a/tests/unit/test_record_processor.py
+++ b/tests/unit/test_record_processor.py
@@ -818,6 +818,36 @@ class TestRecordProcessor(testtools.TestCase):
lambda x: x['date'] == 1385478465, marks), None)
self.assertTrue(homer_mark['x']) # disagreement
+ def test_commit_merge_date(self):
+ record_processor_inst = self.make_record_processor()
+ runtime_storage_inst = record_processor_inst.runtime_storage_inst
+
+ 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,
+ '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.finalize()
+
+ commit = runtime_storage_inst.get_by_primary_key('de7e8f2')
+ self.assertEqual(1385490000, commit['date'])
+
# update records
def _generate_record_commit(self):