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

fix: circleci plugin pagination #7770

Merged
merged 4 commits into from
Jul 25, 2024

Conversation

Nickcw6
Copy link
Contributor

@Nickcw6 Nickcw6 commented Jul 22, 2024

⚠️ Pre Checklist

Please complete ALL items in this checklist, and remove before submitting

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

Summary

Fixes CircleCI plugin where pagination of the API responses was not occurring, resulting in incomplete data collection.

  • Corrected query param name to page-token
  • Set default PageSize ApiCollectorArg to 20, the default page size. Previously this was defaulting to 0 meaning the GetNextPageCustomData arg was being ignored due to this within the exec function.

Does this close any open issues?

Closes #7750

Screenshots

Before fix, max 20 rows (per project) present in _raw_circleci_api_pipelines (ie. 1 page of results):
Screenshot 2024-07-21 at 16 29 59

After fix, now 203 rows from across multiple pages:
Screenshot 2024-07-22 at 10 32 56

Other Information

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug labels Jul 22, 2024
@@ -81,7 +82,7 @@ func CollectJobs(taskCtx plugin.SubTaskContext) errors.Error {
Query: func(reqData *api.RequestData) (url.Values, errors.Error) {
query := url.Values{}
if pageToken, ok := reqData.CustomData.(string); ok && pageToken != "" {
query.Set("page_token", reqData.CustomData.(string))
query.Set("page-token", reqData.CustomData.(string))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think query.Set("page-token", pageToken) is more concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed. Additionally as pipelines, workflows & jobs all were using the same ApiCollectorArgs functions I moved the 3 of them to shared.go

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 23, 2024
@Nickcw6 Nickcw6 force-pushed the fix/circleci-plugin-pagination branch from 4407157 to eb7d274 Compare July 23, 2024 11:34
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 25, 2024
@d4x1 d4x1 merged commit 7ac45c7 into apache:main Jul 25, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugins This issue or PR relates to plugins lgtm This PR has been approved by a maintainer pr-type/bug-fix This PR fixes a bug size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug][CircleCI Plugin] Only collecting first page of API responses
2 participants