Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion forum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Openedx forum app.
"""

__version__ = "0.6.0"
__version__ = "0.6.1"
13 changes: 11 additions & 2 deletions forum/backends/mongodb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,9 +1250,18 @@ def update_comment_and_get_updated_comment(

@staticmethod
def get_commentables_counts_based_on_type(course_id: str) -> dict[str, Any]:
"""Return commentables counts in a course based on thread's type."""
"""Return commentables counts in a course based on thread's type.

Only counts non-deleted threads to match visible posts.
"""
pipeline: list[dict[str, Any]] = [
{"$match": {"course_id": course_id, "_type": "CommentThread"}},
{
"$match": {
"course_id": course_id,
"_type": "CommentThread",
"is_deleted": {"$ne": True}, # Exclude deleted threads
}
},
{
"$group": {
"_id": {"topic_id": "$commentable_id", "type": "$thread_type"},
Expand Down
9 changes: 7 additions & 2 deletions forum/backends/mysql/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,9 +2015,14 @@ def delete_user_comments(

@staticmethod
def get_commentables_counts_based_on_type(course_id: str) -> dict[str, Any]:
"""Return commentables counts in a course based on thread's type."""
"""Return commentables counts in a course based on thread's type.

Only counts non-deleted threads to match visible posts.
"""
result = (
CommentThread.objects.filter(course_id=course_id)
CommentThread.objects.filter(
course_id=course_id, is_deleted=False # Exclude deleted threads
)
.values("commentable_id")
.annotate(
discussion_count=Count(
Expand Down
Loading