From 7394e2568afb57c583ed62111db864f2d9df65e5 Mon Sep 17 00:00:00 2001 From: Naincy Chourasia Date: Tue, 12 May 2026 05:47:55 +0000 Subject: [PATCH 1/2] fix: correct discussion and question counts for moderators in non-courseware topics --- forum/__init__.py | 2 +- forum/backends/mongodb/api.py | 13 +++++++++++-- forum/backends/mysql/api.py | 10 ++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) 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..8f723eef 100644 --- a/forum/backends/mysql/api.py +++ b/forum/backends/mysql/api.py @@ -2015,9 +2015,15 @@ 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( From c3dc49a845dc4e223fdeaa379099293bb028aee0 Mon Sep 17 00:00:00 2001 From: Naincy Chourasia Date: Tue, 12 May 2026 06:12:47 +0000 Subject: [PATCH 2/2] fix: correct discussion and question counts for moderators in non-courseware topics --- forum/backends/mysql/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/forum/backends/mysql/api.py b/forum/backends/mysql/api.py index 8f723eef..8b9ca456 100644 --- a/forum/backends/mysql/api.py +++ b/forum/backends/mysql/api.py @@ -2021,8 +2021,7 @@ def get_commentables_counts_based_on_type(course_id: str) -> dict[str, Any]: """ result = ( CommentThread.objects.filter( - course_id=course_id, - is_deleted=False # Exclude deleted threads + course_id=course_id, is_deleted=False # Exclude deleted threads ) .values("commentable_id") .annotate(