Skip to content

Commit

Permalink
Merge pull request #246 from ibi-group/handle-request-batchid
Browse files Browse the repository at this point in the history
Handle Request batchId
  • Loading branch information
JymDyerIBI authored Aug 26, 2024
2 parents b56f924 + 579dcb7 commit 2a87ce7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 2a87ce7

Please sign in to comment.