bandada-infra / bandada

A system for managing privacy-preserving groups.
https://bandada.pse.dev
MIT License
63 stars 52 forks source link

Implement pagination in the API #312

Open vplasencia opened 11 months ago

vplasencia commented 11 months ago

Description

Right now, when you return the members of a group, you will get all of them together, then it is necessary to allow pagination in the API for lists.

The idea is to integrate pagination into the API.

The first step would be to do some research to find the best solution for Nestjs. Maybe it's better to use a library or do it manually.

Two libraries that can help:

hriztam commented 8 months ago

Can I work on this issue?

vplasencia commented 8 months ago

Hey @hriztam! Yes, sure. Do you want me to assign you this issue?

hriztam commented 8 months ago

Yes

vplasencia commented 8 months ago

@hriztam let us know if you need any help 👍

hriztam commented 8 months ago

I'm having trouble setting up the project

Screenshot 2024-01-23 at 8 32 55 PM
vplasencia commented 8 months ago

Hey @hriztam! These are the steps:

1- Clone the repository: git clone https://github.com/privacy-scaling-explorations/bandada.git 2- Go to the bandada folder: cd bandada 3- Install dependencies: yarn 4- Copy env variables. Run in the project root folder: cp apps/api/.env.example apps/api/.env 5- Start the project: yarn dev 6- Go to http://localhost:3001

I think that step 4 should solve your issue.

hriztam commented 8 months ago

It's working, thanks

vplasencia commented 8 months ago

Great! I will update the Readme file to add that step, thanks for pointing this out.

hriztam commented 8 months ago

Also where will I get this group ids and all

vplasencia commented 8 months ago

Hey @hriztam! I just updated the Readme file. Here is all the info about the application urls: https://github.com/privacy-scaling-explorations/bandada/tree/main?tab=readme-ov-file#application-urls

You can get the data from the API. If you create an off-chain group, you can get the information using this url: http://localhost:3000. The API has a UI, you can play around with it there.

You can also use the Bandada sdk to get the information, but you will need to pass the development url, like so:

const apiSdk = new ApiSdk(SupportedUrl.DEV)

This repo can help with it too: https://github.com/vplasencia/bandada-sdk-demo

aguzmant103 commented 5 months ago

Hey @hriztam ! Thank you for picking up this issue. Were you able to work on it? Any troubles or work pending?

aguzmant103 commented 3 months ago

@hriztam heya, I'm going to unassign this task from you so it's available for anyone to take.

But please let me know if you have progress or need any help to complete it.

ScottyDavies commented 4 weeks ago

Hello @aguzmant103 can I work on this ?

vplasencia commented 3 weeks ago

Hey @ScottyDavies! Do you want me to assign this issue to you?

ScottyDavies commented 3 weeks ago

Yes please

vplasencia commented 3 weeks ago

Hey @ScottyDavies! Done. Thank you. Please let us know if you have questions.

family36 commented 2 weeks ago

Hi, I'm PSE student. I would like to try this. @vplasencia

vplasencia commented 2 weeks ago

Hey @family36! I just assigned the issue to you. Let us know if you have questions.

family36 commented 2 weeks ago

hi @vplasencia I made minimal changes, taking into account the impact on others. The members in the response are limited to 100 per page. Does this modification meet the requirements you intended?

bandada\apps\api\src\app\groups\groups.controller.ts

    @Get(":group")
    @ApiOperation({ description: "Returns a specific group." })
    @ApiCreatedResponse({ type: Group })
    async getGroup(
        @Param("group") groupId: string,
        @Query("page") page?: number
    ) {
        const group = await this.groupsService.getGroup(groupId)
        const fingerprint = await this.groupsService.getFingerprint(groupId)

        let members = group.members

        if (page) {
            const membersPerPage = 100
            const startIndex = (page - 1) * membersPerPage
            members = group.members.slice(
                startIndex,
                startIndex + membersPerPage
            )
        }

        const paginatedGroup = { ...group, members }

        return mapGroupToResponseDTO(paginatedGroup, fingerprint)
    }
vplasencia commented 1 week ago

Hey @family36!

Thank you very much. Yes, the idea is to have something like that. I added a bit more ideas, resources and context for this issue in the issue description. I also removed the good first issue tag because I think this task can be a bit difficult and take some time, and you will also need to understand more about the API code.

Please let me know if you're still interested in working on this issue.

If you prefer to take a look at other good first issues, you can find the list of open good first issues here. Feel free to ask for any other that is not assigned yet.

family36 commented 1 week ago

@vplasencia ok, I will try other good first issue. Thank you!