Skip to content

Commit

Permalink
Update to add 'and' to scanner filter when more than one filter condi…
Browse files Browse the repository at this point in the history
…tion exists.
  • Loading branch information
srpiatt committed Dec 13, 2023
1 parent c990586 commit 707a1df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <swb version>\_<lab version>, 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 707a1df

Please sign in to comment.