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

Handle Request batchId #246

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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)) {
JymDyerIBI marked this conversation as resolved.
Show resolved Hide resolved
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
Loading