diff --git a/forum/__init__.py b/forum/__init__.py index 4b22d55d..af155f75 100644 --- a/forum/__init__.py +++ b/forum/__init__.py @@ -2,4 +2,4 @@ Openedx forum app. """ -__version__ = "0.6.0" +__version__ = "0.6.1" diff --git a/forum/backends/mongodb/api.py b/forum/backends/mongodb/api.py index a94a9687..0f05ad20 100644 --- a/forum/backends/mongodb/api.py +++ b/forum/backends/mongodb/api.py @@ -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"}, diff --git a/forum/backends/mysql/api.py b/forum/backends/mysql/api.py index 4dbcea1b..8b9ca456 100644 --- a/forum/backends/mysql/api.py +++ b/forum/backends/mysql/api.py @@ -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(