From 85faa5a4f5fc686b9ab92898ed72eb988f6525a5 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:23:13 -0500 Subject: [PATCH 1/6] fix: consolidate stop times query, remove onlyRequestForOperators --- lib/actions/apiV2.js | 50 ++++-------------------------- lib/components/map/default-map.tsx | 1 - 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index d1e1b82e4..057f7dfd2 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -499,13 +499,15 @@ export const fetchNearby = (position, radius) => { export const findStopTimesForStop = (params) => function (dispatch, getState) { dispatch(fetchingStopTimesForStop(params)) - const { date, onlyRequestForOperators, stopId } = params + const { date, stopId } = params const timeZone = getState().otp.config.homeTimezone // Create a service date timestamp from 3:30am local. const serviceDay = getServiceStart(date, timeZone).getTime() / 1000 - const fullStopTimesQuery = `query StopTimes( + return dispatch( + createGraphQLQueryAction( + `query StopTimes( $serviceDay: Long! $stopId: String! ) { @@ -540,6 +542,7 @@ export const findStopTimesForStop = (params) => id: code route { agency { + name gtfsId } gtfsId @@ -565,48 +568,7 @@ export const findStopTimesForStop = (params) => } } } - }` - - const shorterStopTimesQueryForOperators = `query StopTimes( - $stopId: String! - ) { - stop(id: $stopId) { - gtfsId - code - routes { - id: gtfsId - agency { - gtfsId - name - } - patterns { - id - headsign - } - } - stoptimesForPatterns(numberOfDepartures: 100, omitNonPickups: true, omitCanceled: false) { - pattern { - desc: name - headsign - id: code - route { - agency { - gtfsId - } - gtfsId - } - } - } - } - }` - - const query = onlyRequestForOperators - ? shorterStopTimesQueryForOperators - : fullStopTimesQuery - - return dispatch( - createGraphQLQueryAction( - query, + }`, { serviceDay, stopId diff --git a/lib/components/map/default-map.tsx b/lib/components/map/default-map.tsx index b2e7b899f..be2bf8935 100644 --- a/lib/components/map/default-map.tsx +++ b/lib/components/map/default-map.tsx @@ -161,7 +161,6 @@ class DefaultMap extends Component { const stopId = entity.gtfsId this.props.findStopTimesForStop({ date: getCurrentDate(), - onlyRequestForOperators: true, stopId }) return From f193f6513a68276f1521b60d3948698dc91954b2 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:13:48 -0500 Subject: [PATCH 2/6] fix query for stops --- lib/actions/apiV2.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index 057f7dfd2..4cbfdb605 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -547,9 +547,6 @@ export const findStopTimesForStop = (params) => } gtfsId } - stops { - gtfsId - } } stoptimes { headsign From a8e5a5d8c08ed3f3db1182974c9c497215f670cd Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:44:56 -0500 Subject: [PATCH 3/6] fix: make transitIndex stops comprehensive list instead of rewriting on each call --- lib/reducers/create-otp-reducer.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/reducers/create-otp-reducer.js b/lib/reducers/create-otp-reducer.js index fa0f082ef..394169926 100644 --- a/lib/reducers/create-otp-reducer.js +++ b/lib/reducers/create-otp-reducer.js @@ -845,6 +845,7 @@ function createOtpReducer(config) { transitIndex: { stops: { $set: { + ...state.transitIndex.stops, [action.payload.stopId]: { fetchStatus: FETCH_STATUS.FETCHING } @@ -856,8 +857,11 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - [action.payload.stopId]: { - fetchStatus: { $set: FETCH_STATUS.FETCHING } + $set: { + ...state.transitIndex.stops, + [action.payload.stopId]: { + fetchStatus: FETCH_STATUS.FETCHING + } } } } @@ -867,7 +871,10 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - [action.payload.gtfsId]: { $set: action.payload } + $set: { + ...state.transitIndex.stops, + [action.payload.gtfsId]: action.payload + } } } }) From ea63467141705a93161a6ce9bc3f30f3cb9e31b5 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:13:14 -0500 Subject: [PATCH 4/6] replace $set wtih $merge for FIND_STOP_TIMES_FOR_STOP --- lib/reducers/create-otp-reducer.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/reducers/create-otp-reducer.js b/lib/reducers/create-otp-reducer.js index 394169926..53b734ba1 100644 --- a/lib/reducers/create-otp-reducer.js +++ b/lib/reducers/create-otp-reducer.js @@ -844,10 +844,9 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - $set: { - ...state.transitIndex.stops, + $merge: { [action.payload.stopId]: { - fetchStatus: FETCH_STATUS.FETCHING + fetchStatus: { $merge: FETCH_STATUS.FETCHING } } } } @@ -857,7 +856,7 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - $set: { + $merge: { ...state.transitIndex.stops, [action.payload.stopId]: { fetchStatus: FETCH_STATUS.FETCHING @@ -871,10 +870,7 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - $set: { - ...state.transitIndex.stops, - [action.payload.gtfsId]: action.payload - } + [action.payload.gtfsId]: { $merge: action.payload } } } }) From 3cc4d3acb178176f618b97dee044be4e83ff5e32 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:23:27 -0500 Subject: [PATCH 5/6] we only need one $merge actually --- lib/reducers/create-otp-reducer.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/reducers/create-otp-reducer.js b/lib/reducers/create-otp-reducer.js index 53b734ba1..975707e02 100644 --- a/lib/reducers/create-otp-reducer.js +++ b/lib/reducers/create-otp-reducer.js @@ -846,7 +846,7 @@ function createOtpReducer(config) { stops: { $merge: { [action.payload.stopId]: { - fetchStatus: { $merge: FETCH_STATUS.FETCHING } + fetchStatus: FETCH_STATUS.FETCHING } } } @@ -856,11 +856,8 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - $merge: { - ...state.transitIndex.stops, - [action.payload.stopId]: { - fetchStatus: FETCH_STATUS.FETCHING - } + [action.payload.stopId]: { + fetchStatus: { $set: FETCH_STATUS.FETCHING } } } } @@ -870,7 +867,7 @@ function createOtpReducer(config) { return update(state, { transitIndex: { stops: { - [action.payload.gtfsId]: { $merge: action.payload } + [action.payload.gtfsId]: { $set: action.payload } } } }) From 2a5e6b928fd8eecc09f46d6b6a640ee591189bb4 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:30:41 -0500 Subject: [PATCH 6/6] Provide transiations for OTP-UI-stopsAndStations layer --- lib/components/map/default-map.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/components/map/default-map.tsx b/lib/components/map/default-map.tsx index 367133ac3..412dc0382 100644 --- a/lib/components/map/default-map.tsx +++ b/lib/components/map/default-map.tsx @@ -86,6 +86,8 @@ function getLayerName(overlay, config, intl) { return intl.formatMessage({ id: 'components.MapLayers.streets' }) case 'Satellite': return intl.formatMessage({ id: 'components.MapLayers.satellite' }) + case 'Stops': + return intl.formatMessage({ id: 'components.MapLayers.stops' }) default: if (name) return name }