Skip to content

Commit 3881c54

Browse files
rdonigianbryanjnelson
authored andcommitted
add blacklist query to handler
1 parent f1d88cd commit 3881c54

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/components/project/handlers/set-department-id.handler.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,16 @@ export class SetDepartmentId implements IEventHandler<SubscribedEvent> {
105105
.where({ 'deptIdNode.value': not(isNull()) })
106106
.return(collect('deptIdNode.value').as('used')),
107107
)
108-
// Distill to available
109-
.with('[id in enumerated where not id in used][0] as next')
108+
// Get blacklisted IDs
109+
.subQuery((sub) =>
110+
sub
111+
.match(node('blacklist', 'BlacklistDepartmentId'))
112+
.return(collect('blacklist.departmentId').as('blacklisted')),
113+
)
114+
// Distill to available (excluding both used AND blacklisted)
115+
.with(
116+
'[id in enumerated where not id in used and not id in blacklisted][0] as next',
117+
)
110118
// collapse cardinality to zero if none available
111119
.raw('unwind next as nextId')
112120

0 commit comments

Comments
 (0)