commit 59d5934097ee25eac0b64a79acb58010d894e2fe
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2025-12-16T12:33:55Z |
| subject | Print special route if only special route matches |
commit 59d5934097ee25eac0b64a79acb58010d894e2fe
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2025-12-16T12:33:55Z
Print special route if only special route matches
---
datasources/mtr/bus/query.go | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/datasources/mtr/bus/query.go b/datasources/mtr/bus/query.go
index 3e9ed04..5ce3e42 100644
--- a/datasources/mtr/bus/query.go
+++ b/datasources/mtr/bus/query.go
@@ -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