mirror of
https://github.com/cjdenio/uta-trax-api.git
synced 2026-12-01 00:26:25 +00:00
frontrunner track prediction
This commit is contained in:
4 files changed
+214
-2
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user