Skip to content

Commit

Permalink
feat: Annotate discussion tree depth using TreeDepth function
Browse files Browse the repository at this point in the history
  • Loading branch information
mireq committed Apr 20, 2024
1 parent ab24f77 commit 1018a6e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion comments/templatetags/comments_tags.py
Expand Up @@ -24,6 +24,7 @@
from comments.utils import get_requested_time
from common_utils import iterify, get_meta
from common_utils.content_types import get_lookups
from common_utils.models import TreeDepth


register = template.Library()
Expand Down Expand Up @@ -226,7 +227,7 @@ def all(self):
attachments_by_comment[attachment[0]].append(AttachmentRecord(*attachment[1:]))
queryset = (queryset
.with_tree_fields()
.extra(select={'tree_depth': '__tree.tree_depth'})
.annotate(tree_depth=TreeDepth())
.values_list('pk', 'created', 'updated', 'ip_address', 'parent_id', 'tree_depth', 'is_public', 'is_removed', 'is_locked', 'subject', 'filtered_comment', 'user_name', 'user_id', 'user__avatar', 'user__email', 'user__username', 'user__first_name', 'user__last_name', 'user__signature', 'user__distribution', 'user__is_active', 'user__is_staff', 'user__is_superuser', 'user__rating__rating')
)
comments = L([CommentRecord(*row) for row in queryset])
Expand Down

0 comments on commit 1018a6e

Please sign in to comment.