-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepared users endpoint for pagination #3861 #3862
base: main
Are you sure you want to change the base?
Prepared users endpoint for pagination #3861 #3862
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution, @sahilpatel342.
I have reviewed the changes and added a few comments.
Ps.
Updated existing tests and added new tests to verify pagination functionality.
This part from the description does not seem to be fitting 🤔
@@ -352,7 352,17 @@ export class AdminController { | |||
@Get('user') | |||
@HasPermission(permissions.accessAdminControl) | |||
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) | |||
public async getUsers(): Promise<AdminUsers> { | |||
return this.adminService.getUsers(); | |||
public async getUsers( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just skip
and take
, you can remove the params for sorting.
@@ -427,8 427,17 @@ export class AdminService { | |||
}; | |||
} | |||
|
|||
public async getUsers(): Promise<AdminUsers> { | |||
return { users: await this.getUsersWithAnalytics() }; | |||
public async getUsers({ skip, take, sortColumn, sortDirection }: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just skip and take, you can remove the params for sorting.
sortColumn?: string; | ||
sortDirection?: Prisma.SortOrder; | ||
}): Promise<AdminUsers> { | ||
return this.userRepository.find({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still use return { users: await this.getUsersWithAnalytics() };
, but pass skip
, take
and integrate them in the query.
Hey @sahilpatel342 Have you had a chance to check and implement the feedback from the code review? Let me know if you need anything! |
This change prepares the users endpoint for pagination #3861
Description:
• Implemented pagination support for the GET /api/v1/admin/user endpoint.
• Added skip, take, sortColumn, and sortDirection query parameters to control pagination and sorting.
• Modified service and repository logic to handle new parameters.
• Updated existing tests and added new tests to verify pagination functionality.
Code Changes:
• Updated controller to accept new query parameters.
• Adjusted service method to handle pagination and sorting.