Skip to content

Commit

Permalink
Add validation report reported_at (#210)
Browse files Browse the repository at this point in the history
* Add validation report reported_at

* Updates

* Schema updates
  • Loading branch information
irees authored Feb 2, 2024
1 parent 6029be1 commit 756502e
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 180 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
Loading

0 comments on commit 756502e

Please sign in to comment.