Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sahilpatel342
Copy link

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.

@dtslvr dtslvr self-requested a review October 3, 2024 06:06
Copy link
Member

@dtslvr dtslvr left a 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(
Copy link
Member

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 }: {
Copy link
Member

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({
Copy link
Member

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.

@dtslvr dtslvr linked an issue Oct 3, 2024 that may be closed by this pull request
@dtslvr
Copy link
Member

dtslvr commented Oct 13, 2024

Hey @sahilpatel342

Have you had a chance to check and implement the feedback from the code review? Let me know if you need anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Prepare users endpoint for pagination
2 participants