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

Total number of items in collection should not be ambiguous #76

Open
zrthxn opened this issue Oct 20, 2021 · 1 comment
Open

Total number of items in collection should not be ambiguous #76

zrthxn opened this issue Oct 20, 2021 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@zrthxn
Copy link
Member

zrthxn commented Oct 20, 2021

Both ChRIS API and Store API, transform the total count of items in any collection to an ambiguous value. If the total item count is greater than zero, it returns totalCount: total; But if it is zero, it returns totalCount: -1 which is counter-intuitive and ambiguous.
If this value is meant to represent errors, those should be represented by the function throwing an error rather than returning a value.

@jennydaman
Copy link
Contributor

/**
* Get the total number of items from a collection object.
*
* @param {Object} collection - Collection+Json collection object
*
* @return {number} - total number of items or -1 if the collection objects
* doesn't contain that information
*/
static getTotalNumberOfItems(collection) {
if (collection.total) {
return collection.total;
}
return -1;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants