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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

total: results.length + Number(truncated),
data: results,
columns: Object.keys(results[0] || {}),
},
Expand Down
8 changes: 4 additions & 4 deletions test/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ describe('Test SSHONify', () => {
},
results: {
limit: 30,
offset: '0',
total: '0',
offset: 0,
total: 30,
columns: [
'checkpoint',
'source',
Expand Down Expand Up @@ -520,8 +520,8 @@ describe('Test SSHONify', () => {
},
results: {
limit: 30,
offset: '0',
total: '0',
offset: 0,
total: 0,
columns: [],
data: [],
},
Expand Down