-
Notifications
You must be signed in to change notification settings - Fork 11
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
Totalfix #928
Conversation
Hello, this is great; any links you can provide to demonstrate that this works? Maybe some API calls that were problematic that you showed me in our video call; now working? |
@MarquiseRosier Yes, try @ci5636/rum-dashboard (before) and @ci5643/rum-dashboard (after). Pick any rum-dashboard query you might have handy in your browser, and try both before and after, with and without an offset querystring parameter. In the resulting JSON, note the differences in results.offset and results.total. |
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.
This looks great!
@@ -162,8 +162,8 @@ export function sshonify(results, description, requestParams, truncated) { | |||
':version': 3, | |||
results: { | |||
limit: Math.max(requestParams.limit || 1, results.length), | |||
offset: requestParams.offset || 0, | |||
total: requestParams.offset || 0 + results.length + (truncated ? 1 : 0), | |||
offset: parseInt(requestParams.offset, 10) || 0, |
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.
offset: parseInt(requestParams.offset, 10) || 0, | |
offset: isNaN(requestParams?.offset) ? 0 : parseInt(requestParams.offset, 10) |
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.
Potential logic issue with the suggested change if offset is not provided, and I do not find the code more readable. Will skip this one but I did commit the other suggestion via ci5650.
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.
@langswei Fair enough; mine is more verbose, both give the same outcome, I assume shorter is better there.
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.
LGTM! Added a couple of syntax suggestions for the sake of readability.
Co-authored-by: David Barrat <[email protected]>
This PR will trigger no release when merged. |
Codecov Report
@@ Coverage Diff @@
## main #928 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 528 528
=========================================
Hits 528 528
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
🎉 This PR is included in version 3.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Fix total count -- previously it only showed the total results if offset was not provided, else it showed the value of offset.
Return type of offset and total is now int.
This change is fully independent of the pagination request. The total field will never exceed limit and should not be interpreted as the total if there were no limit.
Related Issues
#911