-
Notifications
You must be signed in to change notification settings - Fork 101
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: Add configurable pageSize on paginated requests #245
feat: Add configurable pageSize on paginated requests #245
Conversation
404181c
to
039f00a
Compare
Codecov Report
@@ Coverage Diff @@
## main #245 +/- ##
==========================================
+ Coverage 71.19% 71.51% +0.32%
==========================================
Files 78 79 +1
Lines 4180 4227 +47
==========================================
+ Hits 2976 3023 +47
+ Misses 942 937 -5
- Partials 262 267 +5
Continue to review full report at Codecov.
|
41572ae
to
d6c66c7
Compare
We might want to wait for #243 to be merged, and apply the same feature on the new GetBalances route ? |
if pageSize > MaxPageSize { | ||
pageSize = MaxPageSize | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can print a log here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? If we print a log each time the code take a default value, it will give a lot of useless logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, i don't remind if it complete, i have to check, but all requests should be logged using opentelemetry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? If we log each time a default value is used, it will give a lot of logs ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didn't mean especially logging the default value, but logging that the parameter given was higher than expeced. I think this can be useful to determine how our api (and our parameters) are used by our customers in way we didn't predict ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i agree.
Instead of a log, i think an opentelemetry attributes is well suited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdupas22 I checked the instrumentation library used to handle http request (https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin) and it register the full path inside an attribute named "http.target".
d3ba1fc
to
83bc397
Compare
This add the query parameter 'page_size' on both GET /transactions, GET /accounts, and GET /balances endpoints. The parameter is capped to a value of 1000. The default value still the same as before (15). The PR also fix some tests around pagination which was working but was not doing the right thing (see api/controllers/pagination_test.go line 209).
83bc397
to
2bce66b
Compare
fix: first
* feat(api): Add configurable page_size on paginated request. Co-authored-by: Antoine Gelloz <antoine.gelloz@me.com>
Add configurable limit on paginated request
This add the query parameter 'page_size' on both GET /transactions, GET /accounts and GET /balances endpoints.
The parameter is capped to a value of 1000.
The default value still the same as before (15).
The PR also fix some tests around pagination which was working but was not doing the right thing (see api/controllers/pagination_test.go line 209).
Type of change
What parts of the code are impacted ?
Checklist: