Skip to content

Commit

Permalink
Improve response sstatus code when query return no results
Browse files Browse the repository at this point in the history
  • Loading branch information
barreiro committed Oct 25, 2024
1 parent 08b7300 commit 9976302
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/site/content/en/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,10 @@ paths:
description: The run data will be processed asynchronously
content:
text/plain: {}
"204":
description: Data is valid but no run was created
content:
text/plain: {}
"400":
description: Some fields are missing or invalid
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Response add(@QueryParam("test") String testNameOrId,
@APIResponses(value = {
@APIResponse(responseCode = "200", description = "id of the newly generated run", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(type = SchemaType.INTEGER, implementation = Integer.class), example = "101")),
@APIResponse(responseCode = "202", description = "The run data will be processed asynchronously", content = @Content(mediaType = MediaType.TEXT_PLAIN)),
@APIResponse(responseCode = "204", description = "Data is valid but no run was created", content = @Content(mediaType = MediaType.TEXT_PLAIN)),
@APIResponse(responseCode = "400", description = "Some fields are missing or invalid", content = @Content(mediaType = MediaType.APPLICATION_JSON))
})
@Operation(description = "Upload a new Run")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ Response addRunFromData(String start, String stop, String test,
if (datastore.uploadType() == Datastore.UploadType.MUILTI
&& response.payload instanceof ArrayNode) {

if (response.payload.isEmpty()) {
return Response.status(Response.Status.NO_CONTENT).entity("Query returned no results").build();
}

//if we return more than 10 results, offload to async queue to process - this might take a LOOONG time
if (response.payload.size() > 10) {
response.payload.forEach(jsonNode -> {
Expand Down

0 comments on commit 9976302

Please sign in to comment.