From 707a1df8d0cb50f8acde2ffc27f1c924abdb51e8 Mon Sep 17 00:00:00 2001 From: Samantha Piatt Date: Wed, 13 Dec 2023 16:42:46 -0500 Subject: [PATCH] Update to add 'and' to scanner filter when more than one filter condition exists. --- CHANGELOG.md | 3 +++ .../service-catalog/environment-sc-service.js | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 917ce97520..e96ec0793a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. As our fork has diverged from AWS SWB mainline branch, we are noting the SWB version and the lab version together, as \_, starting from SWB mainline, 5.0.0. +## [5.0.0_1.3.1](https://github.com/hms-dbmi/service-workbench-on-aws/compare/v5.0.0_1.3.0...v5.0.0_1.3.1) (12/13/2023) +- Bugfix: Update to add 'and' to scanner filter when more than one filter condition exists. + ## [5.0.0_1.3.0](https://github.com/hms-dbmi/service-workbench-on-aws/compare/v5.0.0_1.2.0...v5.0.0_1.3.0) (12/08/2023) ### Workspaces - Update windows sync to auto-start on user login. diff --git a/addons/addon-base-raas/packages/base-raas-services/lib/environment/service-catalog/environment-sc-service.js b/addons/addon-base-raas/packages/base-raas-services/lib/environment/service-catalog/environment-sc-service.js index b16b33a02d..30be321628 100644 --- a/addons/addon-base-raas/packages/base-raas-services/lib/environment/service-catalog/environment-sc-service.js +++ b/addons/addon-base-raas/packages/base-raas-services/lib/environment/service-catalog/environment-sc-service.js @@ -123,22 +123,23 @@ class EnvironmentScService extends Service { scanner = scanner.start({ id: offsetId }); } + const scannerFilters = []; if (!isAdmin(requestContext)) { const currentUser = _.get(requestContext, 'principalIdentifier.uid'); if (!currentUser) { throw this.boom.badRequest(`Principal Identifier not found`, true); } - scanner = await scanner - .names({ '#c': 'createdBy' }) - .values({ ':c': currentUser }) - .filter('#c = :c'); + scanner = await scanner.names({ '#c': 'createdBy' }).values({ ':c': currentUser }); + scannerFilters.push('#c = :c'); } if (since && isoTimestamp.test(since)) { - scanner = scanner - .names({ '#u': 'updatedAt' }) - .values({ ':u': since }) - .filter('#u >= :u'); + scanner = scanner.names({ '#u': 'updatedAt' }).values({ ':u': since }); + scannerFilters.push('#u >= :u'); + } + + if (scannerFilters.length > 0) { + scanner = scanner.filter(scannerFilters.join(' and ')); } // Only accept fields from a list of allowed db fields