Replace `filterWhen` with `flatMap`

This commit is contained in:
Jon Chambers 2024-07-30 17:34:05 -04:00 committed by Jon Chambers
parent 2104a60703
commit 7e62dc64dc
1 changed files with 5 additions and 6 deletions

View File

@ -84,12 +84,11 @@ public class StartPushNotificationExperimentCommand<T> extends AbstractSinglePas
getCommandDependencies().pushNotificationExperimentSamples(); getCommandDependencies().pushNotificationExperimentSamples();
accounts accounts
.flatMap(account -> Flux.fromIterable(account.getDevices()) .flatMap(account -> Flux.fromIterable(account.getDevices()).map(device -> Tuples.of(account, device)))
.map(device -> Tuples.of(account, device))) .doOnNext(ignored -> DEVICE_INSPECTED_COUNTER.increment())
.doOnNext(ignored -> DEVICE_INSPECTED_COUNTER.increment()) .flatMap(accountAndDevice -> Mono.fromFuture(() ->
.filterWhen(accountAndDevice -> Mono.fromFuture(() -> experiment.isDeviceEligible(accountAndDevice.getT1(), accountAndDevice.getT2()))
experiment.isDeviceEligible(accountAndDevice.getT1(), accountAndDevice.getT2())), .mapNotNull(eligible -> eligible ? accountAndDevice : null), maxConcurrency)
maxConcurrency)
.flatMap(accountAndDevice -> { .flatMap(accountAndDevice -> {
final UUID accountIdentifier = accountAndDevice.getT1().getIdentifier(IdentityType.ACI); final UUID accountIdentifier = accountAndDevice.getT1().getIdentifier(IdentityType.ACI);
final byte deviceId = accountAndDevice.getT2().getId(); final byte deviceId = accountAndDevice.getT2().getId();