Skip to content

Paginated list reversed only gives the first page of results backwards #1136

@micahsteinberg

Description

@micahsteinberg

When I do

g = Github("xxx")
repo = g.get_repo("xxx")

for comm in repo.get_commits(since=datetime).reversed:
    ....

it only goes through the most recent 30 results in reverse order.

I was able to fix this with

def reverse_github_results(paginated_list):
    for i in range(paginated_list.totalCount//30, -1, -1):
        page = paginated_list.get_page(i)
        page.reverse()
        for item in page:
            yield item

but this possibly runs a bit slower and I thought I should let you guys know

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions