# HG changeset patch # User neko259 # Date 2016-05-26 20:06:32 # Node ID cc4b1dfa6b92c24aa0e529f1983731c21aaf2e03 # Parent 573711302de36178a99cc650d1e1075fd7ebf7ce Load only viewable post fields in thread diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -178,17 +178,22 @@ class Thread(models.Model): reply_count - 1) return reply_count - last_replies_count - 1 - def get_replies(self, view_fields_only=False) -> QuerySet: + # TODO Remove argument, it is not used + def get_replies(self, view_fields_only=True) -> QuerySet: """ Gets sorted thread posts """ - query = self.multi_replies.order_by('pub_time').prefetch_related( 'thread', 'attachments') - if view_fields_only: - query = query.defer('poster_ip') return query + def get_viewable_replies(self) -> QuerySet: + """ + Gets replies with only fields that are used for viewing. + """ + return self.get_replies().defer('poster_ip', 'text', 'last_edit_time', + 'version') + def get_top_level_replies(self) -> QuerySet: return self.get_replies().exclude(refposts__threads__in=[self]) diff --git a/boards/templates/boards/thread_normal.html b/boards/templates/boards/thread_normal.html --- a/boards/templates/boards/thread_normal.html +++ b/boards/templates/boards/thread_normal.html @@ -36,7 +36,7 @@ {% endif %}
- {% for post in thread.get_replies %} + {% for post in thread.get_viewable_replies %} {% post_view post reply_link=True %} {% endfor %}