Skip to content

Commit

Permalink
profile query optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
esteban committed Apr 1, 2015
1 parent 9d92b3d commit 7ddea83
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion spirit/managers/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CommentQuerySet(models.QuerySet):
def filter(self, *args, **kwargs):
# TODO: find a better way
return super(CommentQuerySet, self).filter(*args, **kwargs)\
.select_related('user')
.select_related('user__st')

def unremoved(self):
# TODO: remove action
Expand Down
2 changes: 1 addition & 1 deletion spirit/views/comment_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def comment_history_detail(request, comment_id):

comments = CommentHistory.objects\
.filter(comment_fk=comment)\
.select_related('comment_fk__user')\
.select_related('comment_fk__user__st')\
.order_by('date', 'pk')

comments = yt_paginate(
Expand Down
2 changes: 1 addition & 1 deletion spirit/views/topic_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def notification_ajax(request):
notifications = TopicNotification.objects\
.for_access(request.user)\
.order_by("is_read", "-date")\
.select_related('comment__user', 'comment__topic')
.select_related('comment__user__st', 'comment__topic')

notifications = notifications[:settings.ST_NOTIFICATIONS_PER_PAGE]

Expand Down
2 changes: 1 addition & 1 deletion spirit/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def profile_topics(request, pk, slug):
.with_bookmarks(user=request.user)\
.filter(user=p_user)\
.order_by('-date', '-pk')\
.select_related('user')
.select_related('user__st')

topics = yt_paginate(
topics,
Expand Down

0 comments on commit 7ddea83

Please sign in to comment.