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

Consolidate find stop times for stop query #1290

Merged
merged 11 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
53 changes: 6 additions & 47 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!
) {
Expand Down Expand Up @@ -540,13 +542,11 @@ export const findStopTimesForStop = (params) =>
id: code
route {
agency {
name
gtfsId
}
gtfsId
}
stops {
gtfsId
}
}
stoptimes {
headsign
Expand All @@ -565,48 +565,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
Expand Down
3 changes: 2 additions & 1 deletion lib/components/map/default-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the otpUi-stopsandstations layer has "Stops" as the name!
image

return intl.formatMessage({ id: 'components.MapLayers.stops' })
default:
if (name) return name
}
Expand Down Expand Up @@ -166,7 +168,6 @@ class DefaultMap extends Component {
const stopId = firstStopOfStationId || entity.gtfsId
this.props.findStopTimesForStop({
date: getCurrentDate(),
onlyRequestForOperators: true,
stopId
})
return <TransitOperatorIcons stopId={stopId} />
Expand Down
2 changes: 1 addition & 1 deletion lib/reducers/create-otp-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ function createOtpReducer(config) {
return update(state, {
transitIndex: {
stops: {
$set: {
$merge: {
[action.payload.stopId]: {
fetchStatus: FETCH_STATUS.FETCHING
}
Expand Down
Loading