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