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