-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use explicit sort order in get-group-members API
Currently the get-group-members API just returns the list of memberships in whatever order the SQLAlchemy relationship `Group.memberships` returns them, which is undefined. Ultimately we want this API to return memberships sorted by the creation time of the membership itself, oldest first. But we don't currently have a `created` column on the `user_group` table. So for now sort memberships by username instead. I couldn't figure out how to set the sort order of the `Group.memberships` relationship itself to `User.username`: however I try to use the `order_by` argument to this relationship I'm running into various SQLAlchemy errors and I can't find an example in the docs or on Google. GitHub Copilot has no idea ;) So change the view to call `GroupMembersService.get_memberships()` instead of just reading `context.group.memberships`, and add the sort ordering to the query that `GroupMembersService.get_memberships()` does.
- Loading branch information
Showing
5 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters