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

Past Meeting Attendees does not handle pagination #166

Open
matthewbarr opened this issue Jan 31, 2021 · 6 comments
Open

Past Meeting Attendees does not handle pagination #166

matthewbarr opened this issue Jan 31, 2021 · 6 comments

Comments

@matthewbarr
Copy link

"/past_meetings/{}/participants".format(kwargs.get("meeting_id")),

From https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/pastmeetingparticipants:
This request can exceed a single page, and may need to handle the pagination.

{
  "type": "object",
  "description": "Pagination object.",
  "properties": {
    "page_count": {
      "type": "integer",
      "description": "The number of pages returned for the request made."
    },
    "page_size": {
      "type": "integer",
      "description": "The number of records returned within a single API call.",
      "default": 30,
      "maximum": 300
    },
    "total_records": {
      "type": "integer",
      "description": "The number of all records available across pages."
    },
    "next_page_token": {
      "description": "The next page token is used to paginate through large result sets. A next page token will be returned whenever the set of available results exceeds the current page size. The expiration period for this token is 15 minutes.",
      "type": "string"
    },
    "participants": {
    ....
    }
  }
}
@matthewbarr
Copy link
Author

Once I implement a fix, I'll try to upload a PR. I already had an implementation similar to this in my own code, came looking to see if a module had already dealt with it.. Either way, shorter code, and better error handling that my quick attempt.

@matthewbarr
Copy link
Author

(I'm on hold on working on a fix, since this list doesn't provide the join / departure time. I'm going to need to use the report endpoint, instead, but that has a higher scope. )

This is still an issue, and a generic fix to check for pagination is probably the right way to handle it, vs a endpoint specific fix.

@prschmid
Copy link
Owner

@matthewbarr Thanks for bringing this up! Yes, likely a generic way to handle it will be the best option. If you have any ideas of how you might tackle it, I'm all ears. =)

@gfrn
Copy link
Contributor

gfrn commented May 13, 2021

I've modified some code I used in a project to be more generic, tested it and so far it seems great:

def paginated_get_request(self, endpoint, params=None, headers=None):
    if headers is None and self.config.get("version") == API_VERSION_2:
        headers = {"Authorization": "Bearer {}".format(self.config.get("token"))}
        
    next_page_token, data = "",{}
    while True:
        params["next_page_token"] = next_page_token
        content = requests.get(self.url_for(endpoint), params=params, headers=headers, timeout=self.timeout).json()
        next_page_token = content.get("next_page_token")

        for k, v in content.items():
            if type(v) == list:
                if k in data:
                    data[k] += v
                else:
                    data[k] = v

        if not next_page_token:
            break

    for k, v in data.items():
        content[k] = data[k]

    return # What to return?

However, I'm a bit stuck on what should be returned in this case (if applied to the main code base). Response objects are meant to be immutable, so there is a bit of a problem there.

If anyone has any idea of how/what we should return, I'm all ears as well!

@luzer
Copy link

luzer commented Jan 25, 2024

can you share the code you are using?

@gfrn
Copy link
Contributor

gfrn commented Jan 26, 2024

can you share the code you are using?

The project I was working on was very much temporary, and I do not have access to the code base anymore. However, it was very similar to what is written above, except it returned content as a stopgap solution.

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

No branches or pull requests

4 participants