Use the service_route_day table to filter here_result values when there is a more recent applicable serviceID for this day of the week.
The easiest way to do this is keep the query as is and filter results after the fact. This allows
the possibility that a serviceID might expire for one route but still be applicable to another route. This could theoretically happen if the same agency ID re-used the service ID but didn't update files at the same time. Probably a better way to avoid this problem is to use a dataset ID (by URL) rather than relying on agency IDs.
Use the
service_route_day
table to filterhere_result
values when there is a more recent applicable serviceID for this day of the week.The easiest way to do this is keep the query as is and filter results after the fact. This allows the possibility that a serviceID might expire for one route but still be applicable to another route. This could theoretically happen if the same agency ID re-used the service ID but didn't update files at the same time. Probably a better way to avoid this problem is to use a dataset ID (by URL) rather than relying on agency IDs.