diff --git a/src/main/java/org/opentripplanner/middleware/controllers/api/OtpRequestProcessor.java b/src/main/java/org/opentripplanner/middleware/controllers/api/OtpRequestProcessor.java index 61fa1410d..e751cf714 100644 --- a/src/main/java/org/opentripplanner/middleware/controllers/api/OtpRequestProcessor.java +++ b/src/main/java/org/opentripplanner/middleware/controllers/api/OtpRequestProcessor.java @@ -190,12 +190,8 @@ private String proxyPost(Request request, Response response) { * * Other requests will still be proxied, just not stored. */ - QueryVariables queryVariables = getPOJOFromJSON(requestBody, Query.class).variables; - - // Follows the method used in otp-ui core-utils storage.js - String randomBatchId = Integer.toString((int) (Math.random() * 1_000_000_000), 36); - - if (!handlePlanTripResponse(randomBatchId, queryVariables, otpDispatcherResponse, otpUser)) { + Query query = getPOJOFromJSON(requestBody, Query.class); + if (!handlePlanTripResponse(query.batchId, query.variables, otpDispatcherResponse, otpUser)) { logMessageAndHalt( request, HttpStatus.INTERNAL_SERVER_ERROR_500, diff --git a/src/main/java/org/opentripplanner/middleware/otp/graphql/Query.java b/src/main/java/org/opentripplanner/middleware/otp/graphql/Query.java index 7e802eb70..9b5775e2d 100644 --- a/src/main/java/org/opentripplanner/middleware/otp/graphql/Query.java +++ b/src/main/java/org/opentripplanner/middleware/otp/graphql/Query.java @@ -1,7 +1,17 @@ package org.opentripplanner.middleware.otp.graphql; -/** Wraps an OTP GraphQL query data. Field names below are defined by OTP. */ +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * Wraps an OTP GraphQL query data. + * Field names below are defined by OTP, except for batchId which helps group OTP plan requests for a particular search. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) public class Query { + public String batchId; + public String query; public QueryVariables variables;