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

feat(pagination): do it #70

Merged
merged 1 commit into from
Apr 8, 2024
Merged

feat(pagination): do it #70

merged 1 commit into from
Apr 8, 2024

Conversation

ashleygwilliams
Copy link
Member

No description provided.

.json()
.await?;
let mut url = format!("{GITHUB_API}/repos/{owner}/{name}/releases");
let next_pattern = Regex::new(r#"/(?<=<)([\S]*)(?=>; rel="Next")"/i"#).expect("bad regex");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a comment/citation/example for what's up with this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for your own edification it was from the github API docs on their pagination: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2022-11-28. i can't use it because it has look aheads/behinds and the rust regex crate doesn't support that apparently.

this is what the header looks like and i suspect you'll see why its such a pain in the ass to parse:

link: <https://api.github.com/repositories/1300192/issues?per_page=2&page=2>; rel="next", <https://api.github.com/repositories/1300192/issues?per_page=2&page=7715>; rel="last"

anyways you can see my crimes in the commit now that just fully eliminate the regex usage

Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks reasonable

@ashleygwilliams ashleygwilliams force-pushed the pagin branch 2 times, most recently from 36813be to 68249e6 Compare April 6, 2024 00:15
@Gankra
Copy link
Contributor

Gankra commented Apr 8, 2024

status: this apparently hits github api ratelimits :/

@mistydemeo
Copy link
Contributor

status: this apparently hits github api ratelimits :/

This mostly happens if we spam tests; we get 60 requests an hour for unauthenticated apps, which users are less likely to hit in normal circumstances. (I opened #73 to document this.)

@mistydemeo
Copy link
Contributor

I've updated this with updates to the tests, to make sure we don't call it on platforms where the old version is unavailable. I've also added tests for the pagination parser.

@mistydemeo mistydemeo merged commit 8d8d089 into main Apr 8, 2024
13 checks passed
@mistydemeo mistydemeo deleted the pagin branch April 8, 2024 18:59
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

Successfully merging this pull request may close these issues.

3 participants