Skip to content

Commit

Permalink
Updates to reflect changes to calendar/calendar dates (#285)
Browse files Browse the repository at this point in the history
* Updates to reflect changes to calendar/calendar dates
  • Loading branch information
irees authored Oct 31, 2024
1 parent 5cbd2fb commit 2dccef5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 117 deletions.
2 changes: 1 addition & 1 deletion finders/dbfinder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ func (f *Finder) CalendarDatesByServiceID(ctx context.Context, params []model.Ca
return ents, err
},
func(ent *model.CalendarDate) int {
return atoi(ent.ServiceID)
return ent.ServiceID.Int()
},
)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/interline-io/log v0.0.0-20240613202707-4e3adcc06d2d
github.com/interline-io/transitland-dbutil v0.0.0-20241007223837-7564820963d3
github.com/interline-io/transitland-jobs v0.0.0-20241007224018-cfcf2ea0fd72
github.com/interline-io/transitland-lib v1.0.0-rc1.0.20241022212800-cdec759466df
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241031151332-295547f9b448
github.com/interline-io/transitland-mw v0.0.0-20241007223948-3ff905d6e27e
github.com/jmoiron/sqlx v1.4.0
github.com/rs/zerolog v1.33.0
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ github.com/interline-io/transitland-dbutil v0.0.0-20241007223837-7564820963d3 h1
github.com/interline-io/transitland-dbutil v0.0.0-20241007223837-7564820963d3/go.mod h1:kgcAMx0H8Hrg9NCT6pxJhJqtN5itAhEQmaalFQjTGaQ=
github.com/interline-io/transitland-jobs v0.0.0-20241007224018-cfcf2ea0fd72 h1:B22lnyOgSlPfZYSOXlCDRk+QHIPuk0H5/MjKf6jZUto=
github.com/interline-io/transitland-jobs v0.0.0-20241007224018-cfcf2ea0fd72/go.mod h1:8hAqZ//zkgpxGMcGEHPs/zmFNw7DMhkvMl6WyYbCSM0=
github.com/interline-io/transitland-lib v1.0.0-rc1.0.20241022212800-cdec759466df h1:r98zx7A1z9hQw08Iz1o77DWivvD3atag1xNRp2AlFJU=
github.com/interline-io/transitland-lib v1.0.0-rc1.0.20241022212800-cdec759466df/go.mod h1:1H9CH3iavzKjdJjLnhyu5MI35K/ySotez6cotosB0F0=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241030200411-ffcfc6078a00 h1:Yw+wzjk7L7bG7T9dscDZOIiyN26UkayRHj/m3KobIME=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241030200411-ffcfc6078a00/go.mod h1:1H9CH3iavzKjdJjLnhyu5MI35K/ySotez6cotosB0F0=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241031145421-1b92984f9aa1 h1:ybontFeJAQkFh9WPH8OjQ5E1p1AToBWV4EIvv1iLQSQ=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241031145421-1b92984f9aa1/go.mod h1:1H9CH3iavzKjdJjLnhyu5MI35K/ySotez6cotosB0F0=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241031151332-295547f9b448 h1:C3v3Y1c+zVMXZ6qmeqFMxT4JIOEBoOydcREAdlejb+4=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241031151332-295547f9b448/go.mod h1:1H9CH3iavzKjdJjLnhyu5MI35K/ySotez6cotosB0F0=
github.com/interline-io/transitland-mw v0.0.0-20241007223948-3ff905d6e27e h1:XJmgG8Aq9R4rC0FnBocCV1rr9RwEBJFcvnC1WDHmlqI=
github.com/interline-io/transitland-mw v0.0.0-20241007223948-3ff905d6e27e/go.mod h1:3UNXaOzARo8gMTIKReRDGgYXmZ42JhVlS/XW1+q64kQ=
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
Expand Down
129 changes: 32 additions & 97 deletions internal/generated/gqlout/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 4 additions & 16 deletions server/gql/calendar_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,15 @@ import (

type calendarResolver struct{ *Resolver }

// StartDate map time.Time to tt.Date
func (r *calendarResolver) StartDate(ctx context.Context, obj *model.Calendar) (*tt.Date, error) {
a := tt.NewDate(obj.StartDate)
return &a, nil
}

// EndDate map time.Time to tt.Date
func (r *calendarResolver) EndDate(ctx context.Context, obj *model.Calendar) (*tt.Date, error) {
a := tt.NewDate(obj.EndDate)
return &a, nil
}

func (r *calendarResolver) AddedDates(ctx context.Context, obj *model.Calendar, limit *int) ([]*tt.Date, error) {
ents, err := For(ctx).CalendarDatesByServiceID.Load(ctx, model.CalendarDateParam{ServiceID: obj.ID, Limit: checkLimit(limit), Where: nil})()
if err != nil {
return nil, err
}
ret := []*tt.Date{}
for _, ent := range ents {
if ent.ExceptionType == 1 {
x := tt.NewDate(ent.Date)
if ent.ExceptionType.Val == 1 {
x := tt.NewDate(ent.Date.Val)
ret = append(ret, &x)
}
}
Expand All @@ -45,8 +33,8 @@ func (r *calendarResolver) RemovedDates(ctx context.Context, obj *model.Calendar
}
ret := []*tt.Date{}
for _, ent := range ents {
if ent.ExceptionType == 2 {
x := tt.NewDate(ent.Date)
if ent.ExceptionType.Val == 2 {
x := tt.NewDate(ent.Date.Val)
ret = append(ret, &x)
}
}
Expand Down

0 comments on commit 2dccef5

Please sign in to comment.