frontrunner track prediction

This commit is contained in:
cjdenio committed 2026-10-11 13:05:44 -06:00
1 parent 03ded9250d
commit c1ddbd474d
4 files changed
+214 -2

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package gtfs
import (
"database/sql"
"time"
)
func GetActiveServiceIDs(t *time.Time, db *sql.DB) ([]string, error) {
weekday := t.Weekday()
rows, err := db.Query(`select service_id from calendar
WHERE (
case $1
when 0 then sunday
when 1 then monday
when 2 then tuesday
when 3 then wednesday
when 4 then thursday
when 5 then friday
when 6 then saturday
end
) AND $2 >= start_date AND $2 <= end_date
union
select service_id from calendar_dates where date = $2;`, weekday, t.Format("20060102"))
if err != nil {
return nil, err
}
result := []string{}
for rows.Next() {
var serviceId string
rows.Scan(&serviceId)
result = append(result, serviceId)
}
return result, nil
}