Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Jan 17, 2024
1 parent ab7fe1c commit cb703ab
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 201 deletions.
39 changes: 19 additions & 20 deletions actions/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
}
//////
result := model.ValidationResult{}
result.EarliestCalendarDate = tl.Date{}
result.LatestCalendarDate = tl.Date{}
var reader tl.Reader
if src != nil {
// Prepare reader
Expand Down Expand Up @@ -97,12 +95,13 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
}

// Some mapping is necessary because most gql models have some extra fields not in the base tl models.
result.RawResult = r
// result.RawResult = r
result.Success = r.Success
result.FailureReason = r.FailureReason
result.Sha1 = r.SHA1
result.EarliestCalendarDate = r.EarliestCalendarDate
result.LatestCalendarDate = r.LatestCalendarDate
result.Details = model.ValidationResultDetails{}
result.Details.Sha1 = r.Details.SHA1
result.Details.EarliestCalendarDate = r.Details.EarliestCalendarDate
result.Details.LatestCalendarDate = r.Details.LatestCalendarDate
for _, eg := range r.Errors {
if eg == nil {
continue
Expand Down Expand Up @@ -157,26 +156,26 @@ func ValidateUpload(ctx context.Context, src io.Reader, feedURL *string, rturls
}
result.Warnings = append(result.Warnings, eg2)
}
for _, v := range r.FeedInfos {
result.FeedInfos = append(result.FeedInfos, model.FeedInfo{FeedInfo: v})
for _, v := range r.Details.FeedInfos {
result.Details.FeedInfos = append(result.Details.FeedInfos, model.FeedInfo{FeedInfo: v})
}
for _, v := range r.Files {
result.Files = append(result.Files, model.FeedVersionFileInfo{FeedVersionFileInfo: v})
for _, v := range r.Details.Files {
result.Details.Files = append(result.Details.Files, model.FeedVersionFileInfo{FeedVersionFileInfo: v})
}
for _, v := range r.ServiceLevels {
result.ServiceLevels = append(result.ServiceLevels, model.FeedVersionServiceLevel{FeedVersionServiceLevel: v})
for _, v := range r.Details.ServiceLevels {
result.Details.ServiceLevels = append(result.Details.ServiceLevels, model.FeedVersionServiceLevel{FeedVersionServiceLevel: v})
}
for _, v := range r.Agencies {
result.Agencies = append(result.Agencies, model.Agency{Agency: v})
for _, v := range r.Details.Agencies {
result.Details.Agencies = append(result.Details.Agencies, model.Agency{Agency: v})
}
for _, v := range r.Routes {
result.Routes = append(result.Routes, model.Route{Route: v})
for _, v := range r.Details.Routes {
result.Details.Routes = append(result.Details.Routes, model.Route{Route: v})
}
for _, v := range r.Stops {
result.Stops = append(result.Stops, model.Stop{Stop: v})
for _, v := range r.Details.Stops {
result.Details.Stops = append(result.Details.Stops, model.Stop{Stop: v})
}
for _, v := range r.Realtime {
result.Realtime = append(result.Realtime, model.ValidationRealtimeResult{
for _, v := range r.Details.Realtime {
result.Details.Realtime = append(result.Details.Realtime, model.ValidationRealtimeResult{
Url: v.Url,
Json: v.Json,
})
Expand Down
11 changes: 4 additions & 7 deletions actions/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package actions
import (
"context"
"testing"
"time"

"github.com/interline-io/transitland-lib/tldb"
"github.com/interline-io/transitland-lib/validator"
"github.com/interline-io/transitland-server/internal/testconfig"
"github.com/interline-io/transitland-server/internal/testutil"
"github.com/interline-io/transitland-server/model"
Expand Down Expand Up @@ -74,11 +71,11 @@ func TestValidateUpload(t *testing.T) {
tc.f(t, result)
}

atx := tldb.NewPostgresAdapterFromDBX(cfg.Finder.DBX())
// atx := tldb.NewPostgresAdapterFromDBX(cfg.Finder.DBX())
// if err := validator.SaveValidationReport(atx, result.RawResult, time.Now(), 1, ""); err != nil {
// panic(err)
// }

if err := validator.SaveValidationReport(atx, result.RawResult, time.Now(), 1, ""); err != nil {
panic(err)
}
return nil
// jj, _ := json.MarshalIndent(result, "", " ")
// fmt.Println(string(jj))
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/graph-gophers/dataloader/v7 v7.1.0
github.com/hypirion/go-filecache v0.0.0-20160810125507-e3e6ef6981f0
github.com/interline-io/log v0.0.0-20231211003339-8bdc406adcd2
github.com/interline-io/transitland-lib v0.14.1-0.20240112020837-32f59034edf2
github.com/interline-io/transitland-lib v0.14.1-0.20240117011241-ffe744dd523c
github.com/interline-io/transitland-mw v0.0.0-20231220044449-a6aac07a9d9e
github.com/jellydator/ttlcache/v2 v2.11.1
github.com/jmoiron/sqlx v1.3.5
Expand Down Expand Up @@ -126,5 +126,4 @@ require (
)

// replace github.com/interline-io/transitland-lib => /Users/irees/src/interline-io/transitland-lib

// replace github.com/interline-io/transitland-mw => /Users/irees/src/interline-io/transitland-mw
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/interline-io/log v0.0.0-20231211003339-8bdc406adcd2 h1:ScRM8Kr6UwAvblyGMdupRwEy7eWCROPLWmGJf1J1aOk=
github.com/interline-io/log v0.0.0-20231211003339-8bdc406adcd2/go.mod h1:chJaM8SKcHI6ivoeFuZ8M8axTjSV4TPmuQ+sAyAHa34=
github.com/interline-io/transitland-lib v0.14.1-0.20240112020837-32f59034edf2 h1:xlXUQ8kQstr3o+LFASr5RobZqafhFlXOJXN+SR9xMMM=
github.com/interline-io/transitland-lib v0.14.1-0.20240112020837-32f59034edf2/go.mod h1:TwGmZjX/iJRaYWKKosU/TIn8Dt4dywYCAXqmZwAA6qo=
github.com/interline-io/transitland-lib v0.14.1-0.20240117011241-ffe744dd523c h1:R5GCmtVnFoE8idXJgCqAqiJVBKkMf0qxQdPjCH8I6/Y=
github.com/interline-io/transitland-lib v0.14.1-0.20240117011241-ffe744dd523c/go.mod h1:TwGmZjX/iJRaYWKKosU/TIn8Dt4dywYCAXqmZwAA6qo=
github.com/interline-io/transitland-mw v0.0.0-20231220044449-a6aac07a9d9e h1:MZnYbL21CKMWQkNBaG6xnWjU7J7uXErlBM4RwXjIfRQ=
github.com/interline-io/transitland-mw v0.0.0-20231220044449-a6aac07a9d9e/go.mod h1:QyssKyKXwbTWhFT9O08nVj+gScPntMvLh1qMGNr1Ksw=
github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww=
Expand Down
Loading

0 comments on commit cb703ab

Please sign in to comment.