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

API: Add pagination metadata to Workspace module #339

Closed
rajdip-b opened this issue Jul 10, 2024 · 5 comments · Fixed by #387
Closed

API: Add pagination metadata to Workspace module #339

rajdip-b opened this issue Jul 10, 2024 · 5 comments · Fixed by #387
Assignees
Labels
difficulty: 2 foss hack Clustering all the curated issues for Foss Hack 2024 good first issue Good for newcomers help wanted Extra attention is needed priority: high scope: api Everything related to the API type: enhancement New feature or request

Comments

@rajdip-b
Copy link
Member

Description

Refer to #336

Scope of change

  • async getAllMembersOfWorkspace(
    user: User,
    workspaceId: Workspace['id'],
    page: number,
    limit: number,
    sort: string,
    order: string,
    search: string
    ) {
    await this.authorityCheckerService.checkAuthorityOverWorkspace({
    userId: user.id,
    entity: { id: workspaceId },
    authority: Authority.READ_USERS,
    prisma: this.prisma
    })
    return this.prisma.workspaceMember.findMany({
    skip: page * limit,
    take: limit,
    orderBy: {
    workspace: {
    [sort]: order
    }
    },
    where: {
    workspaceId,
    user: {
    OR: [
    {
    name: {
    contains: search
    }
    },
    {
    email: {
    contains: search
    }
    }
    ]
    }
    },
    select: {
    id: true,
    user: true,
    roles: {
    select: {
    id: true,
    role: {
    select: {
    id: true,
    name: true,
    description: true,
    colorCode: true,
    authorities: true,
    projects: {
    select: {
    id: true
    }
    }
    }
    }
    }
    }
    }
    })
    }
  • async getWorkspacesOfUser(
    user: User,
    page: number,
    limit: number,
    sort: string,
    order: string,
    search: string
    ) {
    return this.prisma.workspace.findMany({
    skip: page * limit,
    take: limit,
    orderBy: {
    [sort]: order
    },
    where: {
    members: {
    some: {
    userId: user.id
    }
    },
    OR: [
    {
    name: {
    contains: search
    }
    },
    {
    description: {
    contains: search
    }
    }
    ]
    }
    })
    }
@rajdip-b rajdip-b added type: enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed scope: api Everything related to the API priority: high foss hack Clustering all the curated issues for Foss Hack 2024 difficulty: 2 labels Jul 10, 2024
@rajdip-b rajdip-b changed the title API: Add pagination to Workspace module API: Add pagination metadata to Workspace module Jul 10, 2024
@anjali2004arya
Copy link

Hey, I am Anjali. I am one of the participants of FOSS Hack. I would like to contribute to this issue.

@rajdip-b
Copy link
Member Author

Hey @anjali2004arya! The parent issue is unfortunately already assigned :( Could you please look around the other issues? and see if you can pick anything else up?

@anjali2004arya
Copy link

sure @rajdip-b

@muntaxir4
Copy link
Contributor

/attempt Already working on the parent issue

Copy link

Assigned the issue to @muntaxir4!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 2 foss hack Clustering all the curated issues for Foss Hack 2024 good first issue Good for newcomers help wanted Extra attention is needed priority: high scope: api Everything related to the API type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants