Skip to content

Commit

Permalink
fixed limit issues on datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrosx committed Oct 29, 2024
1 parent 7943a6b commit 8b6e846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
13 changes: 8 additions & 5 deletions common/filter-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ exports.dataset = async (filter) => {
scicatFilter.include = mapIncludeFilter(include);
}
}
if (filter.skip) {
scicatFilter.skip = filter.skip;
}
if (filter.limit) {
scicatFilter.limit = filter.limit;
if (filter.skip || filter.limit) {
scicatFilter.limits = {};
if (filter.skip) {
scicatFilter.limits.skip = filter.skip;
}
if (filter.limit) {
scicatFilter.limits.limit = filter.limit;
}
}
return scicatFilter;
}
Expand Down
12 changes: 7 additions & 5 deletions common/models/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ module.exports = function (Dataset) {
var limit = -1;
// retrieve scoring parameters if enabled
if (pssScoreEnabled) {
// remove limit only if scoreing is enabled
if (filter && Object.keys(filter).includes("limit")) {
limit = filter.limit;
delete filter.limit;
}
// check if query is passed in the filter
if (!query && filter && Object.keys(filter).includes("query")) {
query = filter.query;
delete filter.query;
}
// remove limit only if scoreing is enabled
if (query && filter && Object.keys(filter).includes("limit")) {
limit = filter.limit;
delete filter.limit;
}
}

const scicatFilter = await filterMapper.dataset(filter);
console.log("User Filter " + JSON.stringify(filter));
console.log("SciCat Filter " + JSON.stringify(scicatFilter));
const datasets = await scicatDatasetService.find(scicatFilter);
console.log(datasets.length + " datasets found");

Expand Down

0 comments on commit 8b6e846

Please sign in to comment.