Skip to content

Commit

Permalink
Fix batch controller, make state filter optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pdambrauskas committed May 18, 2022
1 parent 7127b24 commit 978b9a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public static List<ApplicationState> runningStates() {
}

public static Optional<ApplicationState> from(String state) {
if (state == null) {
return Optional.empty();
}

try {
return Optional.of(ApplicationState.valueOf(state));
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.exacaster.lighter.log.LogService;
import com.exacaster.lighter.spark.SubmitParams;
import com.exacaster.lighter.storage.SortOrder;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Delete;
Expand Down Expand Up @@ -39,7 +40,7 @@ public Application create(@Valid @Body SubmitParams batch) {
@Get
public ApplicationList get(@QueryValue(defaultValue = "0") Integer from,
@QueryValue(defaultValue = "100") Integer size,
@QueryValue String state) {
@Nullable @QueryValue String state) {
var batches = ApplicationState.from(state)
.map(st -> batchService.fetchByState(st, SortOrder.DESC, from, size))
.orElseGet(() -> batchService.fetch(from, size));
Expand Down

0 comments on commit 978b9a4

Please sign in to comment.