Commit fa9071d7 authored by Remi Rampin's avatar Remi Rampin

Serve static highlight counts for tags

parent 5844a12e
......@@ -402,6 +402,15 @@ class HighlightTag(Base):
tag = relationship('Tag')
Tag.highlights_count = column_property(
select(
[functions.count(HighlightTag.highlight_id)],
).where(
HighlightTag.tag_id == Tag.id,
).correlate_except(HighlightTag)
)
def connect(db_url):
"""Connect to the database using an environment variable.
"""
......
......@@ -703,8 +703,10 @@ function updateTagsList() {
' <a class="expand-marker">&nbsp;</a> ' +
' <a id="tag-link-' + tag.id + '">' + escapeHtml(tag.path) + '</a>' +
' </div>' +
' <a href="javascript:editTag(' + tag.id + ');" class="badge badge-primary badge-pill">' + gettext("edit") + '</a>' +
//' <span href="#" class="badge badge-primary badge-pill">?</span>' + // TODO: highlight count
' <div>' +
' <span href="#" class="badge badge-secondary badge-pill">' + tag.count + '</span>' +
' <a href="javascript:editTag(' + tag.id + ');" class="badge badge-primary badge-pill">' + gettext("edit") + '</a>' +
' </div>' +
'</div>' +
'<ul class="sublist"></div>';
tags_list.insertBefore(elem, before);
......
......@@ -450,7 +450,8 @@ class Project(BaseHandler):
{
str(tag.id): {'id': tag.id,
'path': tag.path,
'description': tag.description}
'description': tag.description,
'count': tag.highlights_count}
for tag in project.tags
},
sort_keys=True,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment