Implemented review activity log
Change-Id: I14d7471904b4aa82746095a07d9f53d1f685bf40
This commit is contained in:
parent
319ee1af66
commit
f1bc955064
@ -27,6 +27,7 @@ class CachedMemoryStorage(MemoryStorage):
|
||||
|
||||
# common indexes
|
||||
self.records = {}
|
||||
self.primary_key_index = {}
|
||||
self.record_types_index = {}
|
||||
self.module_index = {}
|
||||
self.user_id_index = {}
|
||||
@ -34,6 +35,7 @@ class CachedMemoryStorage(MemoryStorage):
|
||||
self.release_index = {}
|
||||
|
||||
self.indexes = {
|
||||
'primary_key': self.primary_key_index,
|
||||
'record_type': self.record_types_index,
|
||||
'company_name': self.company_index,
|
||||
'module': self.module_index,
|
||||
@ -109,6 +111,13 @@ class CachedMemoryStorage(MemoryStorage):
|
||||
for i in record_ids:
|
||||
yield self.records[i]
|
||||
|
||||
def get_record_by_primary_key(self, primary_key):
|
||||
record_id = list(self.primary_key_index[primary_key])
|
||||
if record_id:
|
||||
return self.records[record_id[0]]
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_original_company_name(self, company_name):
|
||||
normalized = company_name.lower()
|
||||
if normalized not in self.company_name_mapping:
|
||||
|
@ -29,7 +29,11 @@
|
||||
url: make_uri("/data/activity.json"),
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
$("#activity_template").tmpl(data["activity"]).appendTo("#activity_container");
|
||||
{% if metric == 'marks' %}
|
||||
$("#review_activity_template").tmpl(data["activity"]).appendTo("#activity_container");
|
||||
{% else %}
|
||||
$("#commit_activity_template").tmpl(data["activity"]).appendTo("#activity_container");
|
||||
{% endif %}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -61,7 +65,7 @@
|
||||
</script>
|
||||
|
||||
{# Templates #}
|
||||
<script id="activity_template" type="text/x-jquery-tmpl">
|
||||
<script id="commit_activity_template" type="text/x-jquery-tmpl">
|
||||
{% raw %}
|
||||
<div style="margin-bottom: 1em;">
|
||||
<div style='float: left; '><img src="${gravatar}" style="width: 32px; height: 32px;"></div>
|
||||
@ -83,6 +87,23 @@
|
||||
{% endraw %}
|
||||
</script>
|
||||
|
||||
<script id="review_activity_template" type="text/x-jquery-tmpl">
|
||||
{% raw %}
|
||||
<div style="margin-bottom: 1em;">
|
||||
<div style='float: left; '><img src="${gravatar}" style="width: 32px; height: 32px;"></div>
|
||||
<div style="margin-left: 40px;">
|
||||
<div style="font-weight: bold;">{%html author_link %} ({%html company_link %})</div>
|
||||
<div style="font-weight: bold;">${date_str} to <a href="https://launchpad.net/${module}">${module}</a></div>
|
||||
</div>
|
||||
<div style="margin-left: 40px;">
|
||||
<div style='font-weight: bold;'>${subject}</div>
|
||||
<div>Change Id: <a href="${url}">${review_id}</a></div>
|
||||
<div>Review mark: ${value}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endraw %}
|
||||
</script>
|
||||
|
||||
<script id="user_profile_template" type="text/x-jquery-tmpl">
|
||||
{% raw %}
|
||||
<div>
|
||||
|
@ -549,11 +549,22 @@ def get_engineers(records, metric_filter, finalize_handler):
|
||||
return json.dumps(response)
|
||||
|
||||
|
||||
def extend_record(record):
|
||||
record['date_str'] = format_datetime(record['date'])
|
||||
record['author_link'] = make_link(
|
||||
record['author_name'], '/', {'user_id': record['user_id']})
|
||||
record['company_link'] = make_link(
|
||||
record['company_name'], '/',
|
||||
{'company': record['company_name']})
|
||||
record['gravatar'] = gravatar(record['author_email'])
|
||||
|
||||
|
||||
@app.route('/data/activity.json')
|
||||
@exception_handler()
|
||||
@record_filter()
|
||||
def get_activity_json(records):
|
||||
commits = []
|
||||
result = []
|
||||
memory_storage_inst = get_memory_storage()
|
||||
for record in records:
|
||||
if record['record_type'] == 'commit':
|
||||
commit = record.copy()
|
||||
@ -561,16 +572,20 @@ def get_activity_json(records):
|
||||
if 'correction_comment' not in commit:
|
||||
commit['correction_comment'] = ''
|
||||
commit['message'] = make_commit_message(record)
|
||||
commit['date_str'] = format_datetime(commit['date'])
|
||||
commit['author_link'] = make_link(
|
||||
commit['author_name'], '/', {'user_id': commit['user_id']})
|
||||
commit['company_link'] = make_link(
|
||||
commit['company_name'], '/',
|
||||
{'company': commit['company_name']})
|
||||
commit['gravatar'] = gravatar(commit['author_email'])
|
||||
commits.append(commit)
|
||||
commits.sort(key=lambda x: x['date'], reverse=True)
|
||||
return json.dumps({'activity': commits[0:DEFAULT_RECORDS_LIMIT]})
|
||||
extend_record(commit)
|
||||
result.append(commit)
|
||||
elif record['record_type'] == 'mark':
|
||||
review = record.copy()
|
||||
parent = memory_storage_inst.get_record_by_primary_key(
|
||||
review['review_id'])
|
||||
if parent:
|
||||
review['subject'] = parent['subject']
|
||||
review['url'] = parent['url']
|
||||
extend_record(review)
|
||||
result.append(review)
|
||||
|
||||
result.sort(key=lambda x: x['date'], reverse=True)
|
||||
return json.dumps({'activity': result[0:DEFAULT_RECORDS_LIMIT]})
|
||||
|
||||
|
||||
@app.route('/data/contribution.json')
|
||||
|
Loading…
x
Reference in New Issue
Block a user