refacto(users): refacto get /v1/admin/users endpoint toward clean architecture#893
Merged
leoguillaume merged 6 commits intoMay 29, 2026
Conversation
b49bd9c to
4fa19ed
Compare
|
|
||
|
|
||
| @dataclass | ||
| class GetOneUserCommand: |
Member
There was a problem hiding this comment.
On a deux syntaxes pour les use cases de GET
- get routers / get one router (pour providers, routers + users ?)
- get models / get model (pour models et roles )
A choisir je préfère l'option 2
leoguillaume
approved these changes
May 29, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
//: # (# Pull Request Title: refacto(clean-architecture): GET /v1/admin/users and GET /v1/admin/users/{user_id} endpoints)
Overview
Closes #723.
Refactors the
GET /v1/admin/usersandGET /v1/admin/users/{user_id}endpoints toward the clean architecture pattern already applied to other admin endpoints (roles, routers, providers).What was done:
GetOneUserUseCaseandGetUsersUseCasewith their commands and result typesget_user_by_idtoUserRepository(abstract) andPostgresUserRepository(implementation)get_usersinPostgresUserRepository: addedsort_by/sort_orderparameters, fixed thetotalcount bug (filters were not applied to the count query), returnsUserPageinstead of a raw listUserSortField(StrEnum) andUserPageto the user domainUsersResponseschema_USER_COLUMNSconstant inPostgresUserRepositoryto eliminate the SELECT column list duplication (�4 queries)has_expiredproperty toUserWithRoleViewand replaced all inline expiration checks across use cases (�21 files)Definition of Done:
GET /v1/admin/users/{user_id}implemented following clean architectureGET /v1/admin/usersimplemented following clean architecture (pagination, filtering, sorting)GetOneUserUseCaseGetUsersUseCaseGET /v1/admin/users/{user_id}endpointGET /v1/admin/usersendpointPostgresUserRepository.get_user_by_idPostgresUserRepository.get_usersBreaking changes:
GET /v1/admin/users? query parameter names have changed:rolerole_idorganizationorganization_idorder_bysort_byUserSortFieldenum valuesorder_directionsort_orderSortOrderenum valuesemailThe playground has been updated accordingly.
Check lists
Review checklist
If
api/sql/models.pyhas been modified, please confirm that the following steps have been completed:Deployment checklist
Additional Notes
has_expiredrefactoring scopeThe
has_expiredproperty was extracted from inline checks scattered across all use cases. This touched 21 files beyond the scope of this issue but was a necessary cleanup ?import timewas present and used directly in every use case, which was the pre-existing pattern beforeUserWithRoleViewhad the property. All changes are mechanical substitutions with no behavioural impact.emailfilter removalThe old
GET /v1/admin/usersaccepted anemailquery parameter for exact-match filtering. This has been removed because:UserRepositoryabstraction does not expose email-based filtering for list queries (onlyget_user_by_emailfor single-user lookup exists)If email filtering is needed in the future, it can be added as a dedicated use case parameter and repository method.
Tech debt deferred to a follow-up task
The admin authentication check (
has_expired+is_admin) is still duplicated across all 15 admin use cases. Acheck_admin_access()method onUserWithRoleViewwas identified as the correct fix but is out of scope for this PR.