-
Notifications
You must be signed in to change notification settings - Fork 58
only show routes from current service week #1259
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
Changes from all commits
10ca07f
a2a30e2
68e4dcb
1e7fd4f
f908764
7453827
4fb6638
b457c6f
999c8a9
5f1f3a9
b33b1dc
3a5ba46
e8ba3a0
755d729
53afec0
6d8cc92
0e0d16c
0478ca2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import { | |
| isValidSubsequence, | ||
| queryIsValid | ||
| } from '../util/state' | ||
| import { getCurrentServiceWeek } from '../util/current-service-week' | ||
| import { | ||
| getRouteColorBasedOnSettings, | ||
| getRouteIdForPattern, | ||
|
|
@@ -380,14 +381,15 @@ export const fetchNearbyFromStopId = (stopId) => { | |
| ) | ||
| } | ||
|
|
||
| export const fetchNearby = (position, radius) => { | ||
| export const fetchNearby = (position, radius, currentServiceWeek) => { | ||
| const { lat, lon } = position | ||
|
|
||
| return createGraphQLQueryAction( | ||
| `query Nearby( | ||
| $lat: Float! | ||
| $lon: Float! | ||
| $radius: Int | ||
| $currentServiceWeek: LocalDateRangeInput | ||
| ) { | ||
| nearest(lat:$lat, lon:$lon, maxDistance: $radius, first: 100, filterByPlaceTypes: [STOP, VEHICLE_RENT, BIKE_PARK, CAR_PARK]) { | ||
| edges { | ||
|
|
@@ -437,11 +439,15 @@ export const fetchNearby = (position, radius) => { | |
| lon | ||
| code | ||
| gtfsId | ||
| stopRoutes: routes (serviceDates: $currentServiceWeek) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm getting a "Unknown field argument" graphql error back when I try to view a stop
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only works on the latest version of OTP. Are you testing against an older OTP version? I'm happy to delay merging this until newer OTP is more widespread
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh gotcha, yes the instance of OTP I was using to test looks like the only one of ours this would break! We can discuss that internally |
||
| gtfsId | ||
| } | ||
| stoptimesForPatterns { | ||
| pattern { | ||
| headsign | ||
| desc: name | ||
| route { | ||
| gtfsId | ||
| agency { | ||
| name | ||
| gtfsId | ||
|
|
@@ -475,7 +481,7 @@ export const fetchNearby = (position, radius) => { | |
| } | ||
| } | ||
| }`, | ||
| { lat, lon, radius }, | ||
| { currentServiceWeek, lat, lon, radius }, | ||
| fetchNearbyResponse, | ||
| fetchNearbyError, | ||
| { | ||
|
|
@@ -858,10 +864,18 @@ export const findRoute = (params) => | |
|
|
||
| export function findRoutes() { | ||
| return function (dispatch, getState) { | ||
| // Only calculate current service week if the setting for it is enabled | ||
| const currentServiceWeek = | ||
| getState().otp?.config?.routeViewer?.onlyShowCurrentServiceWeek === true | ||
| ? getCurrentServiceWeek() | ||
| : undefined | ||
|
|
||
| dispatch( | ||
| createGraphQLQueryAction( | ||
| `{ | ||
| routes { | ||
| `query Routes( | ||
| $currentServiceWeek: LocalDateRangeInput | ||
| ) { | ||
| routes (serviceDates: $currentServiceWeek) { | ||
| id: gtfsId | ||
| agency { | ||
| id: gtfsId | ||
|
|
@@ -876,7 +890,7 @@ export function findRoutes() { | |
| } | ||
| } | ||
| `, | ||
| {}, | ||
| { currentServiceWeek }, | ||
| findRoutesResponse, | ||
| findRoutesError, | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { addDays, nextSunday, previousSunday } from 'date-fns' | ||
| /** Gets the current service week */ | ||
| export const getCurrentServiceWeek = (): { | ||
| end: string | ||
| start: string | ||
| } => { | ||
| const start = previousSunday(new Date()).toISOString().split('T')[0] | ||
| const end = addDays(nextSunday(new Date()), 1).toISOString().split('T')[0] | ||
| return { end, start } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.