Print special route if only special route matches

This commit is contained in:
2025-12-16 20:33:55 +08:00
parent 36e077c910
commit 59d5934097

View File

@@ -1,7 +1,6 @@
package bus
import (
"log"
"strings"
query "github.com/tgckpg/golifehk/query"
@@ -39,21 +38,24 @@ func Query(lang string, message string) query.IQueryResult {
}
matches := map[*BusStop]*BusStopBuses{}
sMatches := map[*BusStop]*BusStopBuses{}
for _, entry := range *qBusStops.Results {
busStop := any(entry).(*BusStop)
for _, busStopSch := range schedules.BusStops {
if busStopSch.BusStopId == busStop.StationId {
if busStop.RouteId != busStop.ReferenceId {
// There were no indicator for special routes from getSchedule API
log.Printf("Ignoring special route matches: %s", busStop.ReferenceId)
sMatches[busStop] = &busStopSch
continue
}
matches[busStop] = &busStopSch
break
}
}
}
if len(matches) == 0 && 0 < len(sMatches) {
matches = sMatches
}
qr.Schedules = &matches