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

Improve checkpoint pagination support #179

Merged
merged 4 commits into from
Mar 14, 2023

Conversation

ewanharris
Copy link
Contributor

🔧 Changes

Fixes checkpoint pagination and adds tests to the APIs that support it

  • GET /api/v2/logs
    • This works slightly differently to the others as the from parameter here is an ID for a log, not the value returned from the API
  • GET /api/v2/organizations
  • GET /api/v2/organizations/{id}/members
  • GET /api/v2/roles/{id}/users

📚 References

Fixes #109

🔬 Testing

Unit tests added, and pushed the tests before the fix to demonstrate the fix

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@ewanharris ewanharris requested a review from a team as a code owner March 14, 2023 13:51
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (163ac86) 94.88% compared to head (44e1f0d) 94.88%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #179   +/-   ##
=======================================
  Coverage   94.88%   94.88%           
=======================================
  Files          38       38           
  Lines        6807     6810    +3     
=======================================
+ Hits         6459     6462    +3     
  Misses        278      278           
  Partials       70       70           
Impacted Files Coverage Δ
management/management_request.go 83.12% <100.00%> (+0.32%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ewanharris ewanharris changed the title Move IncludeTotals call to before applying options Improve checkpoint pagination support Mar 14, 2023
sergiught
sergiught previously approved these changes Mar 14, 2023
Comment on lines +135 to 139
if l.Next != "" {
return true
}

return l.Total > l.Start+l.Limit
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though we could rewrite this to simply return l.Next != "" || l.Total > l.Start+l.Limit I prefer how you've done it so it's easier to understand what's happening and is less cluttered 👍🏻

@@ -156,10 +160,10 @@ func (o *requestOption) apply(r *http.Request) {
func applyListDefaults(options []RequestOption) RequestOption {
return newRequestOption(func(r *http.Request) {
PerPage(50).apply(r)
IncludeTotals(true).apply(r)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍🏻 this now allows us to also set include totals to false if needed, otherwise it would've been impossible to do so.

@@ -155,7 +155,7 @@ func TestOptionDefaults(t *testing.T) {
assert.Equal(t, "20", perPage)

includeTotals := v.Get("include_totals")
assert.Equal(t, "true", includeTotals)
assert.Equal(t, "false", includeTotals)
Copy link
Contributor

Choose a reason for hiding this comment

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

Totally fine to keep it like this, however there's also the assert.False helper func on the assert pkg.

Widcket
Widcket previously approved these changes Mar 14, 2023
@ewanharris ewanharris dismissed stale reviews from Widcket and sergiught via dbfa976 March 14, 2023 15:00
@ewanharris ewanharris force-pushed the fix/issue-109-checkpoint-pagination branch from 44e1f0d to dbfa976 Compare March 14, 2023 15:00
@ewanharris
Copy link
Contributor Author

Added some better redacting of logs and rebased/force pushed to remove some info

@Widcket
Copy link
Contributor

Widcket commented Mar 14, 2023

rebased/force pushed to remove some info

Note that even if you do this, IIRC the commits are still accessible on GitHub if you have the hash.

@Widcket
Copy link
Contributor

Widcket commented Mar 14, 2023

If any secrets have been pushed (not sure, just in case), the only thing to do is to rotate them.

@ewanharris ewanharris merged commit a49414b into main Mar 14, 2023
@ewanharris ewanharris deleted the fix/issue-109-checkpoint-pagination branch March 14, 2023 15:56
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.

Organizations.List request has bugs with checkpoint paginations params input
4 participants