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

Properly handle pagination of job and took #225

Merged
merged 2 commits into from
Sep 24, 2022

Conversation

tchssk
Copy link
Contributor

@tchssk tchssk commented Sep 20, 2022

Related to #185

GitHub REST API pagination do not return all results at once but instead return the first 30 items by default.
Therefore action-slack shows Job is not found when it be used with workflows including 31 jobs or more.

This pull request fix the problem by using paginate of octokit.

@tchssk tchssk marked this pull request as ready for review September 20, 2022 08:57
@8398a7
Copy link
Owner

8398a7 commented Sep 21, 2022

https://github.com/octokit/plugin-paginate-rest.js

Does this modification refer to all jobs when retrieving one job?
If all jobs are requested even if the expected job is found along the way, the processing time will be very long.

const issues = await octokit.paginate(
  "GET /repos/{owner}/{repo}/issues",
  {
    owner: "octocat",
    repo: "hello-world",
    since: "2010-10-01",
    per_page: 100,
  },
  (response, done) => {
    if (response.data.find((issue) => issue.title.includes("something"))) {
      done();
    }
    return response.data;
  }
);

It seems possible to abort the process when the expected data is returned. Is this appropriate for our requirements?

@tchssk
Copy link
Contributor Author

tchssk commented Sep 21, 2022

Thank you for pointing it out.
It looks good to me. I changed to use the response map function. 88c313b

@codecov
Copy link

codecov bot commented Sep 24, 2022

Codecov Report

Merging #225 (88c313b) into master (e080ee3) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #225   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          238       246    +8     
  Branches        77        79    +2     
=========================================
+ Hits           238       246    +8     
Impacted Files Coverage Δ
src/fields.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@8398a7 8398a7 merged commit 555420c into 8398a7:master Sep 24, 2022
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.

2 participants