Skip to content

Commit

Permalink
[OPIK-159] Address missing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohora committed Oct 4, 2024
1 parent 471cc47 commit 2982f21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ public Mono<Long> delete(Set<UUID> ids) {

return Mono.from(connectionFactory.create())
.flatMapMany(connection -> delete(ids, connection))
.flatMap(Result::getRowsUpdated)
.reduce(Long::sum)
.doFinally(signalType -> {
if (signalType == SignalType.ON_COMPLETE) {
Expand All @@ -551,12 +552,11 @@ public Mono<Long> delete(Set<UUID> ids) {
});
}

private Publisher<Long> delete(Set<UUID> ids, Connection connection) {
private Flux<? extends Result> delete(Set<UUID> ids, Connection connection) {

var statement = connection.createStatement(DELETE_BY_IDS)
.bind("ids", ids.toArray(UUID[]::new));

return makeFluxContextAware(bindWorkspaceIdToFlux(statement))
.flatMap(Result::getRowsUpdated);
return makeFluxContextAware(bindWorkspaceIdToFlux(statement));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ INSERT INTO experiment_items (
;
""";

private static final String DELETE_BY_EXPERIMENT_ID = """
private static final String DELETE_BY_EXPERIMENT_IDS = """
DELETE FROM experiment_items
WHERE experiment_id IN :experiment_ids
AND workspace_id = :workspace_id
Expand Down Expand Up @@ -279,6 +279,7 @@ public Mono<Long> deleteByExperimentIds(Set<UUID> experimentIds) {

return Mono.from(connectionFactory.create())
.flatMapMany(connection -> deleteByExperimentIds(experimentIds, connection))
.flatMap(Result::getRowsUpdated)
.reduce(0L, Long::sum)
.doFinally(signalType -> {
if (signalType == SignalType.ON_COMPLETE) {
Expand All @@ -288,11 +289,10 @@ public Mono<Long> deleteByExperimentIds(Set<UUID> experimentIds) {
});
}

private Publisher<Long> deleteByExperimentIds(Set<UUID> ids, Connection connection) {
Statement statement = connection.createStatement(DELETE_BY_EXPERIMENT_ID)
private Flux<? extends Result> deleteByExperimentIds(Set<UUID> ids, Connection connection) {
Statement statement = connection.createStatement(DELETE_BY_EXPERIMENT_IDS)
.bind("experiment_ids", ids.toArray(UUID[]::new));

return makeFluxContextAware(bindWorkspaceIdToFlux(statement))
.flatMap(Result::getRowsUpdated);
return makeFluxContextAware(bindWorkspaceIdToFlux(statement));
}
}

0 comments on commit 2982f21

Please sign in to comment.