Skip to content

Commit

Permalink
Allow lower case values for feed spec=
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Oct 23, 2023
1 parent acdb5e8 commit 77978ff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server/rest/feed_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rest
import (
_ "embed"
"strconv"
"strings"
)

//go:embed feed_request.gql
Expand Down Expand Up @@ -48,7 +49,7 @@ func (r FeedRequest) Query() (string, map[string]interface{}) {
where["onestop_id"] = r.OnestopID
}
if r.Spec != "" {
where["spec"] = []string{r.Spec}
where["spec"] = []string{checkFeedSpecFilterValue(r.Spec)}
}
if r.Lat != 0.0 && r.Lon != 0.0 {
where["near"] = hw{"lat": r.Lat, "lon": r.Lon, "radius": r.Radius}
Expand Down Expand Up @@ -99,3 +100,12 @@ func (r FeedRequest) ProcessGeoJSON(response map[string]interface{}) error {
}
return processGeoJSON(r, response)
}

func checkFeedSpecFilterValue(v string) string {
v = strings.ToUpper(v)
switch v {
case "GTFS-RT":
return "GTFS_RT"
}
return v
}
17 changes: 17 additions & 0 deletions server/rest/feed_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ func TestFeedRequest(t *testing.T) {
expectSelect: []string{"BA~rt", "CT~rt"},
expectLength: 0,
},
{
name: "spec lower case",
h: &FeedRequest{Spec: "gtfs"},
format: "",
selector: "feeds.#.onestop_id",
expectSelect: []string{"CT", "BA", "HA", "test", "EX"},
expectLength: 0,
},
{
name: "spec lower case dash",
h: &FeedRequest{Spec: "gtfs-rt"},
format: "",
selector: "feeds.#.onestop_id",
expectSelect: []string{"BA~rt", "CT~rt"},
expectLength: 0,
},

{
name: "search",
h: &FeedRequest{Search: "ba"},
Expand Down

0 comments on commit 77978ff

Please sign in to comment.