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.8"
__version__ = "0.6.9"
5 changes: 2 additions & 3 deletions forum/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,10 @@ def _get_stats_for_usernames(
course_id: str, usernames: list[str], backend: Any
) -> list[dict[str, Any]]:
"""Get stats for specific usernames."""
users = backend.get_users()
users = backend.get_users(username__in=usernames)

Comment thread
Alam-2U marked this conversation as resolved.
stats_query = []
for user in users:
if user["username"] not in usernames:
continue
course_stats = user.get("course_stats")
if course_stats:
for course_stat in course_stats:
Expand Down
4 changes: 4 additions & 0 deletions forum/backends/mongodb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,10 @@ def get_course_id_by_comment_id(comment_id: str) -> str | None:
@staticmethod
def get_users(**kwargs: Any) -> list[dict[str, Any]]:
"""Get users."""
kwargs = kwargs.copy()
username_in = kwargs.pop("username__in", None)
if username_in is not None:
kwargs["username"] = {"$in": username_in}
return list(Users().get_list(**kwargs))

@staticmethod
Expand Down
7 changes: 6 additions & 1 deletion forum/backends/mysql/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2606,8 +2606,13 @@ def get_users(**kwargs: Any) -> list[dict[str, Any]]:
Returns:
A list of users.
"""
kwargs = kwargs.copy()
sort_key = kwargs.pop("sort_key", None)
username_in = kwargs.pop("username__in", None)
if username_in is not None:
kwargs["user__username__in"] = username_in

forum_users = ForumUser.objects.filter(**kwargs)
sort_key = kwargs.get("sort_key")
if sort_key:
forum_users = forum_users.order_by(sort_key)

Expand Down
Loading