Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPIK-159] Address missing comments #343

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}