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

Totalfix #928

Merged
merged 5 commits into from
Jul 28, 2023
Merged

Totalfix #928

merged 5 commits into from
Jul 28, 2023

Conversation

langswei
Copy link
Collaborator

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

@MarquiseRosier
Copy link
Collaborator

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?

@langswei
Copy link
Collaborator Author

@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.

Copy link
Collaborator

@MarquiseRosier MarquiseRosier left a 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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
offset: parseInt(requestParams.offset, 10) || 0,
offset: isNaN(requestParams?.offset) ? 0 : parseInt(requestParams.offset, 10)

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

src/util.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@dbrrt dbrrt left a 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]>
@github-actions
Copy link

This PR will trigger no release when merged.

@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Merging #928 (3503245) into main (ce6790e) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #928   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          528       528           
=========================================
  Hits           528       528           
Files Changed Coverage Δ
src/util.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@trieloff trieloff merged commit b2bf28e into main Jul 28, 2023
@trieloff trieloff deleted the totalfix branch July 28, 2023 07:46
@trieloff
Copy link
Contributor

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants