Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Feb 2, 2024
1 parent c953ac9 commit e28e83a
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 37 deletions.
19 changes: 9 additions & 10 deletions actions/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"

"github.com/interline-io/transitland-lib/tl"
"github.com/interline-io/transitland-lib/tl/tt"
"github.com/interline-io/transitland-lib/tlcsv"
"github.com/interline-io/transitland-lib/validator"
"github.com/interline-io/transitland-server/model"
Expand Down Expand Up @@ -47,23 +48,23 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
defer os.Remove(tmpfile.Name())
reader, err = tlcsv.NewReader(tmpfile.Name())
if err != nil {
result.FailureReason = "Could not read file"
result.FailureReason = tt.NewString("Could not read file")
return &result, nil
}
} else if feedURL != nil {
var err error
reader, err = tlcsv.NewReader(*feedURL)
if err != nil {
result.FailureReason = "Could not load URL"
result.FailureReason = tt.NewString("Could not load URL")
return &result, nil
}
} else {
result.FailureReason = "No feed specified"
result.FailureReason = tt.NewString("No feed specified")
return &result, nil
}

if err := reader.Open(); err != nil {
result.FailureReason = "Could not read file"
result.FailureReason = tt.NewString("Could not read file")
return &result, nil
}

Expand All @@ -85,12 +86,12 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls

vt, err := validator.NewValidator(reader, opts)
if err != nil {
result.FailureReason = "Could not validate file"
result.FailureReason = tt.NewString("Could not validate file")
return &result, nil
}
r, err := vt.Validate()
if err != nil {
result.FailureReason = "Could not validate file"
result.FailureReason = tt.NewString("Could not validate file")
return &result, nil
}

Expand All @@ -111,7 +112,6 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
ErrorCode: eg.ErrorCode,
ErrorType: eg.ErrorType,
Count: eg.Count,
Limit: eg.Limit,
}
for _, err := range eg.Errors {
err2 := model.ValidationReportError{
Expand All @@ -121,7 +121,7 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
ErrorCode: eg.ErrorCode,
Line: err.Line,
EntityID: err.EntityID,
Message: err.Error(),
Message: err.Message,
Geometry: err.Geometry,
}
eg2.Errors = append(eg2.Errors, &err2)
Expand All @@ -138,7 +138,6 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
ErrorCode: eg.ErrorCode,
ErrorType: eg.ErrorType,
Count: eg.Count,
Limit: eg.Limit,
}
for _, err := range eg.Errors {
err2 := model.ValidationReportError{
Expand All @@ -148,7 +147,7 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
ErrorCode: eg.ErrorCode,
Line: err.Line,
EntityID: err.EntityID,
Message: err.Error(),
Message: err.Message,
Geometry: err.Geometry,
}
eg2.Errors = append(eg2.Errors, &err2)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/hypirion/go-filecache v0.0.0-20160810125507-e3e6ef6981f0
github.com/interline-io/log v0.0.0-20240126000327-05bb90e4de4f
github.com/interline-io/transitland-dbutil v0.0.0-20240126000951-f2dcc062261d
github.com/interline-io/transitland-lib v0.14.1-0.20240130011910-aca1cf1a05ca
github.com/interline-io/transitland-lib v0.14.1-0.20240202032317-a962b2983040
github.com/interline-io/transitland-mw v0.0.0-20240126001316-f41a91e24d87
github.com/jellydator/ttlcache/v2 v2.11.1
github.com/jmoiron/sqlx v1.3.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ github.com/interline-io/log v0.0.0-20240126000327-05bb90e4de4f h1:yZuyLK/XJqVOHx
github.com/interline-io/log v0.0.0-20240126000327-05bb90e4de4f/go.mod h1:chJaM8SKcHI6ivoeFuZ8M8axTjSV4TPmuQ+sAyAHa34=
github.com/interline-io/transitland-dbutil v0.0.0-20240126000951-f2dcc062261d h1:LL9U0HlBmgq924fQojTSKc7v5VqXdwLVp8ULb701Dz0=
github.com/interline-io/transitland-dbutil v0.0.0-20240126000951-f2dcc062261d/go.mod h1:g10ZeVhMjO+D/DDggLAjqJ4RhYfuQu4MEpgh9vuWmVc=
github.com/interline-io/transitland-lib v0.14.1-0.20240130011910-aca1cf1a05ca h1:03ikQStcESC+8524O/liPdZznbSudJx5ng+1HELD+k8=
github.com/interline-io/transitland-lib v0.14.1-0.20240130011910-aca1cf1a05ca/go.mod h1:QeAjZTDdxWJlD+lGCeoImiM3FsKy8WS1lOQi3/lRydk=
github.com/interline-io/transitland-lib v0.14.1-0.20240202032317-a962b2983040 h1:p0V3ITKNuS7gtJXkmG6OwoiXCBjAMUMpLCzoB5Ivagc=
github.com/interline-io/transitland-lib v0.14.1-0.20240202032317-a962b2983040/go.mod h1:QeAjZTDdxWJlD+lGCeoImiM3FsKy8WS1lOQi3/lRydk=
github.com/interline-io/transitland-mw v0.0.0-20240126001316-f41a91e24d87 h1:uuzbxmdL+vQc4gQIjaERfjmhpfwwo+nTemPRPPbOAwo=
github.com/interline-io/transitland-mw v0.0.0-20240126001316-f41a91e24d87/go.mod h1:BD6S0PL96r/ZWpw4jxRAqnvvcdZKj7Dh0Qqpxsz42AY=
github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww=
Expand Down
4 changes: 4 additions & 0 deletions gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ models:
Key:
model:
- "github.com/interline-io/transitland-lib/tl/tt.Key"
Boolean:
model:
- "github.com/99designs/gqlgen/graphql.Boolean"
- "github.com/interline-io/transitland-lib/tl/tt.Bool"
Bool:
model:
- "github.com/interline-io/transitland-lib/tl/tt.Bool"
Expand Down
52 changes: 36 additions & 16 deletions internal/generated/gqlout/generated.go

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

14 changes: 7 additions & 7 deletions model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,20 @@ func (a *ValueMap) Scan(value interface{}) error {
type ValidationReport struct {
ID int `json:"id"`
FeedVersionID int `json:"feed_version_id"`
Success bool `json:"success"`
FailureReason string `json:"failure_reason"`
IncludesStatic bool `json:"includes_static"`
IncludesRT bool `json:"includes_rt"`
Validator string `json:"validator"`
ValidatorVersion string `json:"validator_version"`
Success tt.Bool `json:"success"`
FailureReason tt.String `json:"failure_reason"`
IncludesStatic tt.Bool `json:"includes_static"`
IncludesRT tt.Bool `json:"includes_rt"`
Validator tt.String `json:"validator"`
ValidatorVersion tt.String `json:"validator_version"`
ReportedAt tt.Time `json:"reported_at"`
Errors []ValidationReportErrorGroup `json:"errors"`
Warnings []ValidationReportErrorGroup `json:"warnings"`
Details ValidationReportDetails
}

type ValidationReportDetails struct {
Sha1 string `json:"sha1"`
Sha1 tt.String `json:"sha1"`
EarliestCalendarDate tl.Date `json:"earliest_calendar_date"`
LatestCalendarDate tl.Date `json:"latest_calendar_date"`
Files []FeedVersionFileInfo `json:"files"`
Expand Down
2 changes: 1 addition & 1 deletion server/gql/mutation_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestValidateGtfsResolver(t *testing.T) {
name: "basic",
query: `mutation($url:String!) {validate_gtfs(url:$url){success failure_reason details{sha1 earliest_calendar_date latest_calendar_date}}}`,
vars: vars,
expect: `{"validate_gtfs":{"details":{"earliest_calendar_date":"2017-10-02","latest_calendar_date":"2019-10-06","sha1":"d2813c293bcfd7a97dde599527ae6c62c98e66c6"},"failure_reason":"","success":true}}`,
expect: `{"validate_gtfs":{"details":{"earliest_calendar_date":"2017-10-02","latest_calendar_date":"2019-10-06","sha1":"d2813c293bcfd7a97dde599527ae6c62c98e66c6"},"failure_reason":null,"success":true}}`,
},
{
name: "files",
Expand Down

0 comments on commit e28e83a

Please sign in to comment.