Skip to content

Commit

Permalink
fix(core-utils): Make query-gen agnostic to OTP plan query params it …
Browse files Browse the repository at this point in the history
…doesn't process.
  • Loading branch information
binh-dam-ibigroup committed Sep 25, 2024
1 parent 975c06f commit 23622fe
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions packages/core-utils/src/query-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,11 @@ export function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {
* @returns A fully formed query+variables ready to be sent to GraphQL backend
*/
export function generateOtp2Query(
{
arriveBy,
banned,
date,
from,
modes,
modeSettings,
numItineraries,
preferred,
time,
to,
unpreferred
}: OTPQueryParams,
otpQueryParams: OTPQueryParams,
planQuery = DefaultPlanQuery
): GraphQLQuery {
const { from, modeSettings, to, ...otherOtpQueryParams } = otpQueryParams;

// This extracts the values from the mode settings to key value pairs
const modeSettingValues = modeSettings.reduce((prev, cur) => {
if (cur.type === "SLIDER" && cur.inverseKey) {
Expand All @@ -247,26 +237,19 @@ export function generateOtp2Query(
const {
bikeReluctance,
carReluctance,
walkSpeed,
walkReluctance,
walkSpeed,
wheelchair
} = modeSettingValues;

return {
query: print(planQuery),
variables: {
arriveBy,
banned,
...otherOtpQueryParams,
bikeReluctance,
carReluctance,
date,
fromPlace: `${from.name}::${from.lat},${from.lon}`,
modes,
numItineraries,
preferred,
time,
toPlace: `${to.name}::${to.lat},${to.lon}`,
unpreferred,
walkReluctance,
walkSpeed,
wheelchair
Expand Down

0 comments on commit 23622fe

Please sign in to comment.