Commit 4981ac03 authored by Martin Peres's avatar Martin Peres

models/bug: only return the comment counts from involves()

This massively reduces the memory pressure and is thus providing a
nice speed improvement.
parent 3aa25d9c
......@@ -435,12 +435,12 @@ class Bug(models.Model, UserFiltrableMixin):
@cached_property
def involves(self):
actors = defaultdict(list)
actors = defaultdict(lambda: 0)
for comment in self.comments_cached:
actors[comment.account].append(comment)
actors[comment.account] += 1
sorted_actors = OrderedDict()
for account in sorted(actors.keys(), key=lambda k: len(actors[k]), reverse=True):
for account in sorted(actors.keys(), key=lambda k: actors[k], reverse=True):
sorted_actors[account] = actors[account]
return sorted_actors
......
......@@ -46,7 +46,7 @@
<td>{% for platform in bug.platforms_list %}{{platform}} {% empty %}No platforms selected{% endfor %}</td>
<td>{% include "CIResults/basic/account.html" with account=bug.assignee %}</td>
<td data-sorttable-customkey="{{bug.effective_priority}}">{{bug.priority}}</td>
<td><ol>{% for actor, comments in bug.involves.items %}<li>{% include "CIResults/basic/account.html" with account=actor %} ({{comments|length}})</li>{% endfor %}</ol></td>
<td><ol>{% for actor, comments_count in bug.involves.items %}<li>{% include "CIResults/basic/account.html" with account=actor %} ({{comments_count}})</li>{% endfor %}</ol></td>
<td data-sorttable-customkey="{{bug.created|date:'U'}}">{{bug.created}}</td>
<td>{{bug.last_updated_by_user|howlongago}}</td>
<td>{{bug.last_updated_by_developer|howlongago}}</td>
......
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