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

Add pagination support to EventsByOrganization query #2319

Closed
Azad99-9 opened this issue May 21, 2024 · 37 comments
Closed

Add pagination support to EventsByOrganization query #2319

Azad99-9 opened this issue May 21, 2024 · 37 comments

Comments

@Azad99-9
Copy link

Is your feature request related to a problem? Please describe.
Currently the EventsByOrganization query fetches all event entries at once.
The number of event entries in the database has drastically increased after adding the Recurring events feature. This has resulted in slow API fetching times.

Describe the solution you'd like
Implement pagination for EventsByOrganization. This will allow fetching events in smaller, manageable sets based on user needs (e.g., number of events per page).

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Approach to be followed (optional)
A clear and concise description of approach to be followed.

Additional context
Add any other context or screenshots about the feature request here.

Potential internship candidates
Please read this if you are planning to apply for a Palisadoes Foundation internship PalisadoesFoundation/talawa#359

@github-actions github-actions bot added the unapproved Unapproved for Pull Request label May 21, 2024
@palisadoes
Copy link
Contributor

@aashimawadhwa @rishav-jha-mech @DMills27 PTAL and comment

@palisadoes
Copy link
Contributor

palisadoes commented May 23, 2024

@xoldd This was discussed frequently in the past, however related to news feeds. PTAL too

@palisadoes
Copy link
Contributor

@Azad99-9 @meetulr Do you think this can be implemented without the UI/UX functionality being affected for both Admin and Mobile?

@Azad99-9
Copy link
Author

@palisadoes For the mobile part the UI should be tweaked to accomodate the pagination.

@meetulr
Copy link

meetulr commented May 23, 2024

Both the admin and mobile will need to be updated simultaneously according to the changes in the API. We'll need contributors for both. Would depend on how the query is modified in the backend. A proper approach should be established first.

@palisadoes
Copy link
Contributor

  1. That's what I figured. We don't want to break the apps.
  2. Will we need to modify the newsfeed and its infinite scrolling?

@xoldd
Copy link
Contributor

xoldd commented May 23, 2024

Would depend on how the query is modified in the backend. A proper approach should be established first.

I've documented the standard approach to be followed throughout talawa-api for implementing pagination using the graphql connections:- https://docs.talawa.io/docs/developers/talawa-api/pagination

Implement pagination for EventsByOrganization

Again, REST like patterns should not to be followed with graphql, relationships and fetching patterns should be expressed in the graph. This is an anti-pattern:-

type Query {
  eventsByOrganization(organizationID: ID!): EventsConnection
}

The events associated to an organization should be exposed like this:-

type Organization {
  events: EventsConnection
}

On the client side querying for the events within an organization would look like this:-

type OrganizationEventsQuery($cursor: String, $limit: Int!, $organizationID: ID!) {
  organization(id: $organizationID) {
    address
    phoneNumber
    events(first: $limit, after: $cursor) {
      edges {
        cursor
        node {
          id
          ...other event fields
        }
      }
      pageInfo {
      ... fields
      }
    }
  }
  name
}

The advantage here is that you can fetch other fields like address, phoneNumber, name etc., that exist on the organization along with the events associated to that organization. This is more efficient because the client only sends 1 network request to fetch everything that is needed. The server takes care of resolving everything listed in the query.

When the next set of events are to be fetched(connection is to be traversed further) a new network request would be made with a non-null value for the $cursor variable. This time there's no need to fetch the organization fields like address, phoneNumber, name etc., because they were already fetched by the very first network request. This would look like this:-

type OrganizationEventsQuery($cursor: String, $limit: Int!, $organizationID: ID!) {
  organization(id: $organizationID) {
    events(first: $limit, after: $cursor) {
      edges {
        cursor
        node {
          id
          ...other event fields
        }
      }
      pageInfo {
      ... fields
      }
    }
  }
}

To understand how the client implementation would work, take a read:-

  1. https://www.apollographql.com/docs/react/pagination/overview
  2. https://www.apollographql.com/docs/react/pagination/core-api
  3. https://www.apollographql.com/docs/react/pagination/cursor-based#relay-style-cursor-pagination
  4. https://commerce.nearform.com/open-source/urql/docs/basics/ui-patterns/#infinite-scrolling
  5. https://commerce.nearform.com/open-source/urql/docs/graphcache/local-resolvers/#pagination

@Azad99-9
Copy link
Author

When the next set of events are to be fetched(connection is to be traversed further) a new network request would be made with a non-null value for the $cursor variable. This time there's no need to fetch the organization fields like address, phoneNumber, name etc., because they were already fetched by the very first network request. This would look like this:-

Yes we already use a similar approach in organizationsConnection query.

@palisadoes
Copy link
Contributor

@Azad99-9 Are you working on this?

@Azad99-9
Copy link
Author

Azad99-9 commented Jun 2, 2024

@palisadoes I am not working on this. But this needs to be addressed. To resolve client side performance issues.

@xoldd
Copy link
Contributor

xoldd commented Jun 2, 2024

Should I do it?

@Azad99-9
Copy link
Author

Azad99-9 commented Jun 2, 2024

Yes kindly do it. Thanks.

@Maniii97
Copy link

Maniii97 commented Jun 6, 2024

hey, is this issue up? can i be assigned to do this?.

@Cioppolo14
Copy link
Contributor

@Maniii97 Thank you for your interest. Please keep looking, as I'm sure we have open issues and we'd love your help. If any issue is already assigned, please don't ask to be assigned. We want everyone to get a chance.

Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Jun 17, 2024
@AnshulKahar2729
Copy link

Please assign me this issue, I would like to work on this.

@Cioppolo14
Copy link
Contributor

@xoldd Are you working on this?

@xoldd
Copy link
Contributor

xoldd commented Aug 12, 2024

@xoldd Are you working on this?

I had made a PR that incorporated the required changes but it was failing the prettier formatting test which I wasn't able to fix on my local system. So, Peter closed the PR. I'm currently not working on this anymore so you can assign it to @AnshulKahar2729.

@AnshulKahar2729 You can reference my PR and make a similar PR.

@AnshulKahar2729
Copy link

@xoldd Are you working on this?

I had made a PR that incorporated the required changes but it was failing the prettier formatting test which I wasn't able to fix on my local system. So, Peter closed the PR. I'm currently not working on this anymore so you can assign it to @AnshulKahar2729.

@AnshulKahar2729 You can reference my PR and make a similar PR.

Ok I will do that

@Cioppolo14 Cioppolo14 assigned AnshulKahar2729 and unassigned xoldd Aug 12, 2024
@github-actions github-actions bot removed the no-issue-activity No issue activity label Aug 13, 2024
@AnshulKahar2729
Copy link

@xoldd Are you working on this?

I had made a PR that incorporated the required changes but it was failing the prettier formatting test which I wasn't able to fix on my local system. So, Peter closed the PR. I'm currently not working on this anymore so you can assign it to @AnshulKahar2729.

@AnshulKahar2729 You can reference my PR and make a similar PR.

Ok I will do that

Working on this... Will soon raise a PR.

Copy link

github-actions bot commented Sep 3, 2024

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Sep 15, 2024
@AnshulKahar2729
Copy link

working

Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Sep 27, 2024
@AnshulKahar2729
Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

Working on this... I am just solving another issue too.

@github-actions github-actions bot removed the no-issue-activity No issue activity label Sep 28, 2024
@palisadoes
Copy link
Contributor

Unassigning. Inactivity

@zakhaev26
Copy link

can i work on this issue? @palisadoes
currently learning the tools and exploring talawa softwares. this would help me learn more!

Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Oct 16, 2024
@palisadoes
Copy link
Contributor

unassigning. inactivity

@github-actions github-actions bot removed the no-issue-activity No issue activity label Oct 28, 2024
@prashantrai-30
Copy link

Hey @palisadoes,
I would like to on this.
Can you assign this to me :)

@VijeshVS
Copy link

VijeshVS commented Nov 6, 2024

Hi @palisadoes,
I’d like to take on this issue and implement the suggested pagination for the EventsByOrganization query.

Proposed Steps:
Fetch event entries batch-wise to improve API performance and reduce loading times.
Display events with pagination to manage and navigate entries more effectively.

Thank you!

@palisadoes
Copy link
Contributor

During the week of November 11, 2024 we will start a code freeze on the develop branches in Talawa, Talawa Admin and Talawa-API.

We have completed a project to convert the Talawa-API backend to use PostgreSQL. Work will then begin with us merging code in the develop branches to a new develop-postrgres branch in each repository.

Planning activities for this will be managed in our #talawa-projects slack channel. A GitHub project will be created to track specially labeled issues. We completed a similar exercise last year using a similar methodology.

Starting November 12, California time no new PRs will be accepted against the develop branch. They must be applied to the develop-postrgres branch.

There are some GSoC project features that will need to be merged into develop. These will be the only exceptions.

This activity and the post GSoC 2024 start date was announced in our #general Slack channel last month as a pinned post.

Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Nov 21, 2024
@Cioppolo14 Cioppolo14 removed the no-issue-activity No issue activity label Nov 21, 2024
@VijeshVS
Copy link

Someone can take up this issue as i am not working on this

@VijeshVS VijeshVS removed their assignment Nov 24, 2024
@GriffinAnnshual
Copy link

I'm willing to take it up, can I work on this?

@palisadoes
Copy link
Contributor

We have to close this as the new functionality is being applied to the API with the Postgres migration

@palisadoes palisadoes closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests