@@ -155,15 +155,9 @@ func (api *RestAPI) arrivalsAndDeparturesForStopHandler(w http.ResponseWriter, r
155155 }
156156
157157 // Get trips that serve this stop and are active today
158- activeTrips , err := api .GtfsManager .GtfsDB .Queries .GetTripsByServiceID (ctx , activeServiceIDs )
159- if err != nil {
160- api .serverErrorResponse (w , r , err )
161- return
162- }
163-
164- activeTripIDs := make (map [string ]bool )
165- for _ , trip := range activeTrips {
166- activeTripIDs [trip .ID ] = true
158+ activeServiceIDSet := make (map [string ]bool , len (activeServiceIDs ))
159+ for _ , sid := range activeServiceIDs {
160+ activeServiceIDSet [sid ] = true
167161 }
168162
169163 // Get all stop times for this stop within the time window
@@ -180,7 +174,7 @@ func (api *RestAPI) arrivalsAndDeparturesForStopHandler(w http.ResponseWriter, r
180174 // Filter stop times to only include active trips
181175 var stopTimes []gtfsdb.GetStopTimesForStopInWindowRow
182176 for _ , st := range allStopTimes {
183- if activeTripIDs [st .TripID ] {
177+ if activeServiceIDSet [st .ServiceID ] {
184178 stopTimes = append (stopTimes , st )
185179 }
186180 }
@@ -193,14 +187,14 @@ func (api *RestAPI) arrivalsAndDeparturesForStopHandler(w http.ResponseWriter, r
193187 // Add the current stop
194188 stopIDSet [stop .ID ] = true
195189
196- serviceDateMillis := params .Time .UnixMilli ()
197190 serviceMidnight := time .Date (
198191 params .Time .Year (),
199192 params .Time .Month (),
200193 params .Time .Day (),
201194 0 , 0 , 0 , 0 ,
202195 loc ,
203196 )
197+ serviceDateMillis := serviceMidnight .UnixMilli ()
204198
205199 batchRouteIDs := make (map [string ]bool )
206200 batchTripIDs := make (map [string ]bool )
0 commit comments