diff --git a/actions/validate.go b/actions/validate.go index 6d8c9900..96448d19 100644 --- a/actions/validate.go +++ b/actions/validate.go @@ -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 @@ -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 @@ -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, }) diff --git a/actions/validate_test.go b/actions/validate_test.go index 3191f38f..8995d703 100644 --- a/actions/validate_test.go +++ b/actions/validate_test.go @@ -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" @@ -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)) diff --git a/go.mod b/go.mod index a73947eb..6802a8df 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 5655b42d..2784f43d 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/generated/gqlout/generated.go b/internal/generated/gqlout/generated.go index 3f4e7326..f3c8205c 100644 --- a/internal/generated/gqlout/generated.go +++ b/internal/generated/gqlout/generated.go @@ -935,10 +935,16 @@ type ComplexityRoot struct { } ValidationResult struct { + Details func(childComplexity int) int + Errors func(childComplexity int) int + FailureReason func(childComplexity int) int + Success func(childComplexity int) int + Warnings func(childComplexity int) int + } + + ValidationResultDetails struct { Agencies func(childComplexity int, limit *int) int EarliestCalendarDate func(childComplexity int) int - Errors func(childComplexity int) int - FailureReason func(childComplexity int) int FeedInfos func(childComplexity int, limit *int) int Files func(childComplexity int) int LatestCalendarDate func(childComplexity int) int @@ -947,8 +953,6 @@ type ComplexityRoot struct { ServiceLevels func(childComplexity int, limit *int, routeID *string) int Sha1 func(childComplexity int) int Stops func(childComplexity int, limit *int) int - Success func(childComplexity int) int - Warnings func(childComplexity int) int } ValidationResultError struct { @@ -5821,24 +5825,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidationRealtimeResult.Url(childComplexity), true - case "ValidationResult.agencies": - if e.complexity.ValidationResult.Agencies == nil { - break - } - - args, err := ec.field_ValidationResult_agencies_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.ValidationResult.Agencies(childComplexity, args["limit"].(*int)), true - - case "ValidationResult.earliest_calendar_date": - if e.complexity.ValidationResult.EarliestCalendarDate == nil { + case "ValidationResult.details": + if e.complexity.ValidationResult.Details == nil { break } - return e.complexity.ValidationResult.EarliestCalendarDate(childComplexity), true + return e.complexity.ValidationResult.Details(childComplexity), true case "ValidationResult.errors": if e.complexity.ValidationResult.Errors == nil { @@ -5854,95 +5846,114 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidationResult.FailureReason(childComplexity), true - case "ValidationResult.feed_infos": - if e.complexity.ValidationResult.FeedInfos == nil { + case "ValidationResult.success": + if e.complexity.ValidationResult.Success == nil { break } - args, err := ec.field_ValidationResult_feed_infos_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.ValidationResult.FeedInfos(childComplexity, args["limit"].(*int)), true + return e.complexity.ValidationResult.Success(childComplexity), true - case "ValidationResult.files": - if e.complexity.ValidationResult.Files == nil { + case "ValidationResult.warnings": + if e.complexity.ValidationResult.Warnings == nil { break } - return e.complexity.ValidationResult.Files(childComplexity), true + return e.complexity.ValidationResult.Warnings(childComplexity), true - case "ValidationResult.latest_calendar_date": - if e.complexity.ValidationResult.LatestCalendarDate == nil { + case "ValidationResultDetails.agencies": + if e.complexity.ValidationResultDetails.Agencies == nil { break } - return e.complexity.ValidationResult.LatestCalendarDate(childComplexity), true + args, err := ec.field_ValidationResultDetails_agencies_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - case "ValidationResult.realtime": - if e.complexity.ValidationResult.Realtime == nil { + return e.complexity.ValidationResultDetails.Agencies(childComplexity, args["limit"].(*int)), true + + case "ValidationResultDetails.earliest_calendar_date": + if e.complexity.ValidationResultDetails.EarliestCalendarDate == nil { break } - return e.complexity.ValidationResult.Realtime(childComplexity), true + return e.complexity.ValidationResultDetails.EarliestCalendarDate(childComplexity), true - case "ValidationResult.routes": - if e.complexity.ValidationResult.Routes == nil { + case "ValidationResultDetails.feed_infos": + if e.complexity.ValidationResultDetails.FeedInfos == nil { break } - args, err := ec.field_ValidationResult_routes_args(context.TODO(), rawArgs) + args, err := ec.field_ValidationResultDetails_feed_infos_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.ValidationResult.Routes(childComplexity, args["limit"].(*int)), true + return e.complexity.ValidationResultDetails.FeedInfos(childComplexity, args["limit"].(*int)), true - case "ValidationResult.service_levels": - if e.complexity.ValidationResult.ServiceLevels == nil { + case "ValidationResultDetails.files": + if e.complexity.ValidationResultDetails.Files == nil { break } - args, err := ec.field_ValidationResult_service_levels_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return e.complexity.ValidationResultDetails.Files(childComplexity), true + + case "ValidationResultDetails.latest_calendar_date": + if e.complexity.ValidationResultDetails.LatestCalendarDate == nil { + break } - return e.complexity.ValidationResult.ServiceLevels(childComplexity, args["limit"].(*int), args["route_id"].(*string)), true + return e.complexity.ValidationResultDetails.LatestCalendarDate(childComplexity), true - case "ValidationResult.sha1": - if e.complexity.ValidationResult.Sha1 == nil { + case "ValidationResultDetails.realtime": + if e.complexity.ValidationResultDetails.Realtime == nil { break } - return e.complexity.ValidationResult.Sha1(childComplexity), true + return e.complexity.ValidationResultDetails.Realtime(childComplexity), true - case "ValidationResult.stops": - if e.complexity.ValidationResult.Stops == nil { + case "ValidationResultDetails.routes": + if e.complexity.ValidationResultDetails.Routes == nil { break } - args, err := ec.field_ValidationResult_stops_args(context.TODO(), rawArgs) + args, err := ec.field_ValidationResultDetails_routes_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.ValidationResult.Stops(childComplexity, args["limit"].(*int)), true + return e.complexity.ValidationResultDetails.Routes(childComplexity, args["limit"].(*int)), true - case "ValidationResult.success": - if e.complexity.ValidationResult.Success == nil { + case "ValidationResultDetails.service_levels": + if e.complexity.ValidationResultDetails.ServiceLevels == nil { break } - return e.complexity.ValidationResult.Success(childComplexity), true + args, err := ec.field_ValidationResultDetails_service_levels_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - case "ValidationResult.warnings": - if e.complexity.ValidationResult.Warnings == nil { + return e.complexity.ValidationResultDetails.ServiceLevels(childComplexity, args["limit"].(*int), args["route_id"].(*string)), true + + case "ValidationResultDetails.sha1": + if e.complexity.ValidationResultDetails.Sha1 == nil { break } - return e.complexity.ValidationResult.Warnings(childComplexity), true + return e.complexity.ValidationResultDetails.Sha1(childComplexity), true + + case "ValidationResultDetails.stops": + if e.complexity.ValidationResultDetails.Stops == nil { + break + } + + args, err := ec.field_ValidationResultDetails_stops_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.ValidationResultDetails.Stops(childComplexity, args["limit"].(*int)), true case "ValidationResultError.entity_id": if e.complexity.ValidationResultError.EntityID == nil { @@ -6166,6 +6177,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputStopTimeFilter, ec.unmarshalInputTripFilter, ec.unmarshalInputTripStopTimeFilter, + ec.unmarshalInputValidationReportFilter, ec.unmarshalInputWaypointInput, ) first := true @@ -6648,6 +6660,11 @@ input OperatorFilter { near: PointRadius } +input ValidationReportFilter { + success: Boolean + validator: String +} + input FeedVersionFilter { import_status: ImportStatus feed_onestop_id: String @@ -7073,6 +7090,7 @@ type FeedVersion { stops(limit: Int, where: StopFilter): [Stop!]! trips(limit: Int, where: TripFilter): [Trip!]! feed_infos(limit: Int): [FeedInfo!]! + # validation_reports(limit: Int, where: ValidationReportFilter): [ValidationResult!] } type FeedVersionFileInfo { @@ -7607,7 +7625,10 @@ type ValidationResult { failure_reason: String! errors: [ValidationResultErrorGroup!]! warnings: [ValidationResultErrorGroup!]! - # FeedVersion-like + details: ValidationResultDetails +} + +type ValidationResultDetails { sha1: String! earliest_calendar_date: Date latest_calendar_date: Date @@ -9141,7 +9162,7 @@ func (ec *executionContext) field_Trip_stop_times_args(ctx context.Context, rawA return args, nil } -func (ec *executionContext) field_ValidationResult_agencies_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_ValidationResultDetails_agencies_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int @@ -9156,7 +9177,7 @@ func (ec *executionContext) field_ValidationResult_agencies_args(ctx context.Con return args, nil } -func (ec *executionContext) field_ValidationResult_feed_infos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_ValidationResultDetails_feed_infos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int @@ -9171,7 +9192,7 @@ func (ec *executionContext) field_ValidationResult_feed_infos_args(ctx context.C return args, nil } -func (ec *executionContext) field_ValidationResult_routes_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_ValidationResultDetails_routes_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int @@ -9186,7 +9207,7 @@ func (ec *executionContext) field_ValidationResult_routes_args(ctx context.Conte return args, nil } -func (ec *executionContext) field_ValidationResult_service_levels_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_ValidationResultDetails_service_levels_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int @@ -9210,7 +9231,7 @@ func (ec *executionContext) field_ValidationResult_service_levels_args(ctx conte return args, nil } -func (ec *executionContext) field_ValidationResult_stops_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_ValidationResultDetails_stops_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int @@ -27648,26 +27669,8 @@ func (ec *executionContext) fieldContext_Mutation_validate_gtfs(ctx context.Cont return ec.fieldContext_ValidationResult_errors(ctx, field) case "warnings": return ec.fieldContext_ValidationResult_warnings(ctx, field) - case "sha1": - return ec.fieldContext_ValidationResult_sha1(ctx, field) - case "earliest_calendar_date": - return ec.fieldContext_ValidationResult_earliest_calendar_date(ctx, field) - case "latest_calendar_date": - return ec.fieldContext_ValidationResult_latest_calendar_date(ctx, field) - case "files": - return ec.fieldContext_ValidationResult_files(ctx, field) - case "service_levels": - return ec.fieldContext_ValidationResult_service_levels(ctx, field) - case "agencies": - return ec.fieldContext_ValidationResult_agencies(ctx, field) - case "routes": - return ec.fieldContext_ValidationResult_routes(ctx, field) - case "stops": - return ec.fieldContext_ValidationResult_stops(ctx, field) - case "feed_infos": - return ec.fieldContext_ValidationResult_feed_infos(ctx, field) - case "realtime": - return ec.fieldContext_ValidationResult_realtime(ctx, field) + case "details": + return ec.fieldContext_ValidationResult_details(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ValidationResult", field.Name) }, @@ -40649,8 +40652,71 @@ func (ec *executionContext) fieldContext_ValidationResult_warnings(ctx context.C return fc, nil } -func (ec *executionContext) _ValidationResult_sha1(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_sha1(ctx, field) +func (ec *executionContext) _ValidationResult_details(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResult_details(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Details, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(model.ValidationResultDetails) + fc.Result = res + return ec.marshalOValidationResultDetails2githubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐValidationResultDetails(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ValidationResult_details(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidationResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sha1": + return ec.fieldContext_ValidationResultDetails_sha1(ctx, field) + case "earliest_calendar_date": + return ec.fieldContext_ValidationResultDetails_earliest_calendar_date(ctx, field) + case "latest_calendar_date": + return ec.fieldContext_ValidationResultDetails_latest_calendar_date(ctx, field) + case "files": + return ec.fieldContext_ValidationResultDetails_files(ctx, field) + case "service_levels": + return ec.fieldContext_ValidationResultDetails_service_levels(ctx, field) + case "agencies": + return ec.fieldContext_ValidationResultDetails_agencies(ctx, field) + case "routes": + return ec.fieldContext_ValidationResultDetails_routes(ctx, field) + case "stops": + return ec.fieldContext_ValidationResultDetails_stops(ctx, field) + case "feed_infos": + return ec.fieldContext_ValidationResultDetails_feed_infos(ctx, field) + case "realtime": + return ec.fieldContext_ValidationResultDetails_realtime(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ValidationResultDetails", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidationResultDetails_sha1(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_sha1(ctx, field) if err != nil { return graphql.Null } @@ -40680,9 +40746,9 @@ func (ec *executionContext) _ValidationResult_sha1(ctx context.Context, field gr return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_sha1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_sha1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -40693,8 +40759,8 @@ func (ec *executionContext) fieldContext_ValidationResult_sha1(ctx context.Conte return fc, nil } -func (ec *executionContext) _ValidationResult_earliest_calendar_date(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_earliest_calendar_date(ctx, field) +func (ec *executionContext) _ValidationResultDetails_earliest_calendar_date(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_earliest_calendar_date(ctx, field) if err != nil { return graphql.Null } @@ -40721,9 +40787,9 @@ func (ec *executionContext) _ValidationResult_earliest_calendar_date(ctx context return ec.marshalODate2githubᚗcomᚋinterlineᚑioᚋtransitlandᚑlibᚋtlᚋttᚐDate(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_earliest_calendar_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_earliest_calendar_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -40734,8 +40800,8 @@ func (ec *executionContext) fieldContext_ValidationResult_earliest_calendar_date return fc, nil } -func (ec *executionContext) _ValidationResult_latest_calendar_date(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_latest_calendar_date(ctx, field) +func (ec *executionContext) _ValidationResultDetails_latest_calendar_date(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_latest_calendar_date(ctx, field) if err != nil { return graphql.Null } @@ -40762,9 +40828,9 @@ func (ec *executionContext) _ValidationResult_latest_calendar_date(ctx context.C return ec.marshalODate2githubᚗcomᚋinterlineᚑioᚋtransitlandᚑlibᚋtlᚋttᚐDate(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_latest_calendar_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_latest_calendar_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -40775,8 +40841,8 @@ func (ec *executionContext) fieldContext_ValidationResult_latest_calendar_date(c return fc, nil } -func (ec *executionContext) _ValidationResult_files(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_files(ctx, field) +func (ec *executionContext) _ValidationResultDetails_files(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_files(ctx, field) if err != nil { return graphql.Null } @@ -40806,9 +40872,9 @@ func (ec *executionContext) _ValidationResult_files(ctx context.Context, field g return ec.marshalNFeedVersionFileInfo2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐFeedVersionFileInfoᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -40839,8 +40905,8 @@ func (ec *executionContext) fieldContext_ValidationResult_files(ctx context.Cont return fc, nil } -func (ec *executionContext) _ValidationResult_service_levels(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_service_levels(ctx, field) +func (ec *executionContext) _ValidationResultDetails_service_levels(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_service_levels(ctx, field) if err != nil { return graphql.Null } @@ -40870,9 +40936,9 @@ func (ec *executionContext) _ValidationResult_service_levels(ctx context.Context return ec.marshalNFeedVersionServiceLevel2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐFeedVersionServiceLevelᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_service_levels(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_service_levels(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -40909,15 +40975,15 @@ func (ec *executionContext) fieldContext_ValidationResult_service_levels(ctx con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_ValidationResult_service_levels_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_ValidationResultDetails_service_levels_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _ValidationResult_agencies(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_agencies(ctx, field) +func (ec *executionContext) _ValidationResultDetails_agencies(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_agencies(ctx, field) if err != nil { return graphql.Null } @@ -40947,9 +41013,9 @@ func (ec *executionContext) _ValidationResult_agencies(ctx context.Context, fiel return ec.marshalNAgency2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐAgencyᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_agencies(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_agencies(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -41006,15 +41072,15 @@ func (ec *executionContext) fieldContext_ValidationResult_agencies(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_ValidationResult_agencies_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_ValidationResultDetails_agencies_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _ValidationResult_routes(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_routes(ctx, field) +func (ec *executionContext) _ValidationResultDetails_routes(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_routes(ctx, field) if err != nil { return graphql.Null } @@ -41044,9 +41110,9 @@ func (ec *executionContext) _ValidationResult_routes(ctx context.Context, field return ec.marshalNRoute2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐRouteᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_routes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_routes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -41121,15 +41187,15 @@ func (ec *executionContext) fieldContext_ValidationResult_routes(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_ValidationResult_routes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_ValidationResultDetails_routes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _ValidationResult_stops(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_stops(ctx, field) +func (ec *executionContext) _ValidationResultDetails_stops(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_stops(ctx, field) if err != nil { return graphql.Null } @@ -41159,9 +41225,9 @@ func (ec *executionContext) _ValidationResult_stops(ctx context.Context, field g return ec.marshalNStop2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐStopᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_stops(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_stops(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -41246,15 +41312,15 @@ func (ec *executionContext) fieldContext_ValidationResult_stops(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_ValidationResult_stops_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_ValidationResultDetails_stops_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _ValidationResult_feed_infos(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_feed_infos(ctx, field) +func (ec *executionContext) _ValidationResultDetails_feed_infos(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_feed_infos(ctx, field) if err != nil { return graphql.Null } @@ -41284,9 +41350,9 @@ func (ec *executionContext) _ValidationResult_feed_infos(ctx context.Context, fi return ec.marshalNFeedInfo2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐFeedInfoᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_feed_infos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_feed_infos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -41323,15 +41389,15 @@ func (ec *executionContext) fieldContext_ValidationResult_feed_infos(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_ValidationResult_feed_infos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_ValidationResultDetails_feed_infos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _ValidationResult_realtime(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResult) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ValidationResult_realtime(ctx, field) +func (ec *executionContext) _ValidationResultDetails_realtime(ctx context.Context, field graphql.CollectedField, obj *model.ValidationResultDetails) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidationResultDetails_realtime(ctx, field) if err != nil { return graphql.Null } @@ -41358,9 +41424,9 @@ func (ec *executionContext) _ValidationResult_realtime(ctx context.Context, fiel return ec.marshalOValidationRealtimeResult2ᚕgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐValidationRealtimeResultᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ValidationResult_realtime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ValidationResultDetails_realtime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ValidationResult", + Object: "ValidationResultDetails", Field: field, IsMethod: false, IsResolver: false, @@ -45917,6 +45983,40 @@ func (ec *executionContext) unmarshalInputTripStopTimeFilter(ctx context.Context return it, nil } +func (ec *executionContext) unmarshalInputValidationReportFilter(ctx context.Context, obj interface{}) (model.ValidationReportFilter, error) { + var it model.ValidationReportFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"success", "validator"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "success": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("success")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Success = data + case "validator": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("validator")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Validator = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputWaypointInput(ctx context.Context, obj interface{}) (model.WaypointInput, error) { var it model.WaypointInput asMap := map[string]interface{}{} @@ -53976,47 +54076,83 @@ func (ec *executionContext) _ValidationResult(ctx context.Context, sel ast.Selec if out.Values[i] == graphql.Null { out.Invalids++ } + case "details": + out.Values[i] = ec._ValidationResult_details(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var validationResultDetailsImplementors = []string{"ValidationResultDetails"} + +func (ec *executionContext) _ValidationResultDetails(ctx context.Context, sel ast.SelectionSet, obj *model.ValidationResultDetails) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, validationResultDetailsImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ValidationResultDetails") case "sha1": - out.Values[i] = ec._ValidationResult_sha1(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_sha1(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "earliest_calendar_date": - out.Values[i] = ec._ValidationResult_earliest_calendar_date(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_earliest_calendar_date(ctx, field, obj) case "latest_calendar_date": - out.Values[i] = ec._ValidationResult_latest_calendar_date(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_latest_calendar_date(ctx, field, obj) case "files": - out.Values[i] = ec._ValidationResult_files(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_files(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "service_levels": - out.Values[i] = ec._ValidationResult_service_levels(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_service_levels(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "agencies": - out.Values[i] = ec._ValidationResult_agencies(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_agencies(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "routes": - out.Values[i] = ec._ValidationResult_routes(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_routes(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "stops": - out.Values[i] = ec._ValidationResult_stops(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_stops(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "feed_infos": - out.Values[i] = ec._ValidationResult_feed_infos(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_feed_infos(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "realtime": - out.Values[i] = ec._ValidationResult_realtime(ctx, field, obj) + out.Values[i] = ec._ValidationResultDetails_realtime(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -59531,6 +59667,10 @@ func (ec *executionContext) marshalOValidationResult2ᚖgithubᚗcomᚋinterline return ec._ValidationResult(ctx, sel, v) } +func (ec *executionContext) marshalOValidationResultDetails2githubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐValidationResultDetails(ctx context.Context, sel ast.SelectionSet, v model.ValidationResultDetails) graphql.Marshaler { + return ec._ValidationResultDetails(ctx, sel, &v) +} + func (ec *executionContext) marshalOWaypoint2ᚖgithubᚗcomᚋinterlineᚑioᚋtransitlandᚑserverᚋmodelᚐWaypoint(ctx context.Context, sel ast.SelectionSet, v *model.Waypoint) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/model/models.go b/model/models.go index 78202776..68251d4e 100644 --- a/model/models.go +++ b/model/models.go @@ -263,21 +263,25 @@ func (a *ValueMap) Scan(value interface{}) error { // ValidationResult . type ValidationResult struct { - RawResult *validator.Result - Success bool `json:"success"` - FailureReason string `json:"failure_reason"` - Errors []ValidationResultErrorGroup `json:"errors"` - Warnings []ValidationResultErrorGroup `json:"warnings"` - Sha1 string `json:"sha1"` - EarliestCalendarDate tl.Date `json:"earliest_calendar_date"` - LatestCalendarDate tl.Date `json:"latest_calendar_date"` - Files []FeedVersionFileInfo `json:"files"` - ServiceLevels []FeedVersionServiceLevel `json:"service_levels"` - Agencies []Agency `json:"agencies"` - Routes []Route `json:"routes"` - Stops []Stop `json:"stops"` - FeedInfos []FeedInfo `json:"feed_infos"` - Realtime []ValidationRealtimeResult `json:"realtime"` + RawResult *validator.Result + Success bool `json:"success"` + FailureReason string `json:"failure_reason"` + Errors []ValidationResultErrorGroup `json:"errors"` + Warnings []ValidationResultErrorGroup `json:"warnings"` + Details ValidationResultDetails +} + +type ValidationResultDetails struct { + Sha1 string `json:"sha1"` + EarliestCalendarDate tl.Date `json:"earliest_calendar_date"` + LatestCalendarDate tl.Date `json:"latest_calendar_date"` + Files []FeedVersionFileInfo `json:"files"` + ServiceLevels []FeedVersionServiceLevel `json:"service_levels"` + Agencies []Agency `json:"agencies"` + Routes []Route `json:"routes"` + Stops []Stop `json:"stops"` + FeedInfos []FeedInfo `json:"feed_infos"` + Realtime []ValidationRealtimeResult `json:"realtime"` } type ValidationRealtimeResult struct { diff --git a/model/models_gen.go b/model/models_gen.go index 47f7a089..dec15586 100644 --- a/model/models_gen.go +++ b/model/models_gen.go @@ -388,6 +388,11 @@ type TripStopTimeFilter struct { End *tt.WideTime `json:"end,omitempty"` } +type ValidationReportFilter struct { + Success *bool `json:"success,omitempty"` + Validator *string `json:"validator,omitempty"` +} + type ValidationResultErrorGroup struct { Filename string `json:"filename"` ErrorType string `json:"error_type"` diff --git a/schema/input.graphqls b/schema/input.graphqls index d6695753..34b2a320 100644 --- a/schema/input.graphqls +++ b/schema/input.graphqls @@ -26,6 +26,11 @@ input OperatorFilter { near: PointRadius } +input ValidationReportFilter { + success: Boolean + validator: String +} + input FeedVersionFilter { import_status: ImportStatus feed_onestop_id: String diff --git a/schema/schema.graphqls b/schema/schema.graphqls index 7c828ded..35684dc2 100644 --- a/schema/schema.graphqls +++ b/schema/schema.graphqls @@ -192,6 +192,7 @@ type FeedVersion { stops(limit: Int, where: StopFilter): [Stop!]! trips(limit: Int, where: TripFilter): [Trip!]! feed_infos(limit: Int): [FeedInfo!]! + # validation_reports(limit: Int, where: ValidationReportFilter): [ValidationResult!] } type FeedVersionFileInfo { @@ -726,7 +727,10 @@ type ValidationResult { failure_reason: String! errors: [ValidationResultErrorGroup!]! warnings: [ValidationResultErrorGroup!]! - # FeedVersion-like + details: ValidationResultDetails +} + +type ValidationResultDetails { sha1: String! earliest_calendar_date: Date latest_calendar_date: Date diff --git a/server/gql/mutation_resolver_test.go b/server/gql/mutation_resolver_test.go index 2e180b6d..f9673879 100644 --- a/server/gql/mutation_resolver_test.go +++ b/server/gql/mutation_resolver_test.go @@ -1,6 +1,7 @@ package gql import ( + "fmt" "io/ioutil" "net/http" "net/http/httptest" @@ -71,43 +72,43 @@ func TestValidateGtfsResolver(t *testing.T) { testcases := []testcase{ { name: "basic", - query: `mutation($url:String!) {validate_gtfs(url:$url){success failure_reason sha1 earliest_calendar_date latest_calendar_date}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){success failure_reason details{sha1 earliest_calendar_date latest_calendar_date}}}`, vars: vars, - expect: `{"validate_gtfs":{"earliest_calendar_date":"2017-10-02","failure_reason":"","latest_calendar_date":"2019-10-06","sha1":"d2813c293bcfd7a97dde599527ae6c62c98e66c6","success":true}}`, + expect: `{"validate_gtfs":{"details":{"earliest_calendar_date":"2017-10-02","latest_calendar_date":"2019-10-06","sha1":"d2813c293bcfd7a97dde599527ae6c62c98e66c6"},"failure_reason":"","success":true}}`, }, { name: "files", - query: `mutation($url:String!) {validate_gtfs(url:$url){files{name size rows sha1 header csv_like}}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){details{files{name size rows sha1 header csv_like}}}}`, vars: vars, - selector: "validate_gtfs.files.#.name", + selector: "validate_gtfs.details.files.#.name", selectExpect: []string{"agency.txt", "calendar.txt", "calendar_attributes.txt", "calendar_dates.txt", "directions.txt", "fare_attributes.txt", "fare_rules.txt", "farezone_attributes.txt", "frequencies.txt", "realtime_routes.txt", "routes.txt", "shapes.txt", "stop_attributes.txt", "stop_times.txt", "stops.txt", "transfers.txt", "trips.txt"}, }, { name: "agencies", - query: `mutation($url:String!) {validate_gtfs(url:$url){agencies{agency_id}}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){details{agencies{agency_id}}}}`, vars: vars, - selector: "validate_gtfs.agencies.#.agency_id", + selector: "validate_gtfs.details.agencies.#.agency_id", selectExpect: []string{"caltrain-ca-us"}, }, { name: "routes", - query: `mutation($url:String!) {validate_gtfs(url:$url){routes{route_id}}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){details{routes{route_id}}}}`, vars: vars, - selector: "validate_gtfs.routes.#.route_id", + selector: "validate_gtfs.details.routes.#.route_id", selectExpect: []string{"Bu-130", "Li-130", "Lo-130", "TaSj-130", "Gi-130", "Sp-130"}, }, { name: "stops", - query: `mutation($url:String!) {validate_gtfs(url:$url){stops{stop_id}}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){details{stops{stop_id}}}}`, vars: vars, - selector: "validate_gtfs.stops.#.stop_id", + selector: "validate_gtfs.details.stops.#.stop_id", selectExpect: []string{"70011", "70012", "70021", "70022", "70031", "70032", "70041", "70042", "70051", "70052", "70061", "70062", "70071", "70072", "70081", "70082", "70091", "70092", "70101", "70102", "70111", "70112", "70121", "70122", "70131", "70132", "70141", "70142", "70151", "70152", "70161", "70162", "70171", "70172", "70191", "70192", "70201", "70202", "70211", "70212", "70221", "70222", "70231", "70232", "70241", "70242", "70251", "70252", "70261", "70262", "70271", "70272", "70281", "70282", "70291", "70292", "70301", "70302", "70311", "70312", "70321", "70322", "777402", "777403"}, }, { name: "feed_infos", // none present :( - query: `mutation($url:String!) {validate_gtfs(url:$url){feed_infos{feed_publisher_name}}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){details{feed_infos{feed_publisher_name}}}}`, vars: vars, - selector: "validate_gtfs.feed_infos.#.feed_publisher_name", + selector: "validate_gtfs.details.feed_infos.#.feed_publisher_name", selectExpect: []string{}, }, { @@ -123,12 +124,16 @@ func TestValidateGtfsResolver(t *testing.T) { vars: vars, selector: "validate_gtfs.warnings.#.filename", selectExpect: []string{"routes.txt", "routes.txt", "trips.txt"}, // now includes an additional validation warning + f: func(t *testing.T, jj string) { + fmt.Println("JJ:", jj) + + }, }, { name: "service_levels", - query: `mutation($url:String!) {validate_gtfs(url:$url){service_levels{start_date end_date monday tuesday wednesday thursday friday saturday sunday}}}`, + query: `mutation($url:String!) {validate_gtfs(url:$url){details{service_levels{start_date end_date monday tuesday wednesday thursday friday saturday sunday}}}}`, vars: vars, - selector: "validate_gtfs.service_levels.#.thursday", + selector: "validate_gtfs.details.service_levels.#.thursday", selectExpect: []string{"485220", "485220", "485220", "485220", "155940", "485220", "485220", "485220", "485220", "485220", "485220", "485220", "485220", "485220", "485220", "485220", "490680", "485220", "485220", "485220", "485220"}, // todo: better checking... }, // RT tests