diff --git a/.test.env b/.test.env index 457a7c6e..b1932a87 100644 --- a/.test.env +++ b/.test.env @@ -11,7 +11,7 @@ DB_SCHEMA=internal/database/mariadb/init/schema.sql DB_CONTAINER_IMAGE=mariadb:latest -DOCKER_IMAGE_REGISTRY=hub.docker.com +DOCKER_IMAGE_REGISTRY=index.docker.io DOCKER_CREDENTIAL_STORE=docker-credential-desktop diff --git a/internal/api/graphql/gqlgen.yml b/internal/api/graphql/gqlgen.yml index 73502754..a9d55b18 100644 --- a/internal/api/graphql/gqlgen.yml +++ b/internal/api/graphql/gqlgen.yml @@ -191,6 +191,22 @@ models: resolver: true services: resolver: true + IssueMatchFilterValue: + fields: + status: + resolver: false + severity: + resolver: false + issueType: + resolver: false + primaryName: + resolver: true + affectedService: + resolver: true + componentName: + resolver: true + supportGroupName: + resolver: true ServiceFilterValue: fields: serviceName: diff --git a/internal/api/graphql/graph/baseResolver/common.go b/internal/api/graphql/graph/baseResolver/common.go index 22a016d2..0696d1e0 100644 --- a/internal/api/graphql/graph/baseResolver/common.go +++ b/internal/api/graphql/graph/baseResolver/common.go @@ -14,10 +14,29 @@ import ( ) var ( - FilterServiceName string = "Service Name" - FilterSupportGroupName string = "SupportGroup Name" - FilterUserName string = "User Name" - FilterUniqueUserID string = "Unique User ID" + FilterDisplayServiceName string = "Service Name" + FilterDisplaySupportGroupName string = "Support Group Name" + FilterDisplayUserName string = "User Name" + FilterDisplayUniqueUserId string = "Unique User ID" + FilterDisplayComponentName string = "Component Name" + FilterDisplayIssueType string = "Issue Type" + FilterDisplayIssueMatchStatus string = "Issue Match Status" + FilterDisplayIssuePrimaryName string = "Issue Name" + FilterDisplayIssueSeverity string = "Severity" + + ServiceFilterServiceName string = "serviceName" + ServiceFilterUniqueUserId string = "uniqueUserId" + ServiceFilterType string = "type" + ServiceFilterUserName string = "userName" + ServiceFilterSupportGroupName string = "supportGroupName" + + IssueMatchFilterPrimaryName string = "primaryName" + IssueMatchFilterComponentName string = "componentName" + IssueMatchFilterIssueType string = "issueType" + IssueMatchFilterStatus string = "status" + IssueMatchFilterSeverity string = "severity" + IssueMatchFilterAffectedService string = "affectedService" + IssueMatchFilterSupportGroupName string = "supportGroupName" ) type ResolverError struct { diff --git a/internal/api/graphql/graph/baseResolver/component.go b/internal/api/graphql/graph/baseResolver/component.go index 2fec640c..40460e31 100644 --- a/internal/api/graphql/graph/baseResolver/component.go +++ b/internal/api/graphql/graph/baseResolver/component.go @@ -106,3 +106,40 @@ func ComponentBaseResolver(app app.Heureka, ctx context.Context, filter *model.C return &connection, nil } + +func ComponentNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.ComponentFilter) (*model.FilterItem, error) { + requestedFields := GetPreloads(ctx) + logrus.WithFields(logrus.Fields{ + "requestedFields": requestedFields, + }).Debug("Called ComponentNameBaseResolver") + + if filter == nil { + filter = &model.ComponentFilter{} + } + + f := &entity.ComponentFilter{ + Paginated: entity.Paginated{}, + Name: filter.ComponentName, + } + + opt := GetListOptions(requestedFields) + + names, err := app.ListComponentNames(f, opt) + + if err != nil { + return nil, NewResolverError("ComponentNameBaseReolver", err.Error()) + } + + var pointerNames []*string + + for _, name := range names { + pointerNames = append(pointerNames, &name) + } + + filterItem := model.FilterItem{ + DisplayName: &FilterDisplayComponentName, + Values: pointerNames, + } + + return &filterItem, nil +} diff --git a/internal/api/graphql/graph/baseResolver/issue.go b/internal/api/graphql/graph/baseResolver/issue.go index 2e686596..d07a11d0 100644 --- a/internal/api/graphql/graph/baseResolver/issue.go +++ b/internal/api/graphql/graph/baseResolver/issue.go @@ -157,3 +157,46 @@ func IssueBaseResolver(app app.Heureka, ctx context.Context, filter *model.Issue return &connection, nil } + +func IssueNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.IssueFilter) (*model.FilterItem, error) { + requestedFields := GetPreloads(ctx) + logrus.WithFields(logrus.Fields{ + "requestedFields": requestedFields, + }).Debug("Called IssueNameBaseResolver") + + if filter == nil { + filter = &model.IssueFilter{} + } + + f := &entity.IssueFilter{ + Paginated: entity.Paginated{}, + ServiceName: filter.AffectedService, + PrimaryName: filter.PrimaryName, + Type: lo.Map(filter.IssueType, func(item *model.IssueTypes, _ int) *string { return pointer.String(item.String()) }), + Search: filter.Search, + IssueMatchStatus: nil, //@todo Implement + IssueMatchDiscoveryDate: nil, //@todo Implement + IssueMatchTargetRemediationDate: nil, //@todo Implement + } + + opt := GetListOptions(requestedFields) + + names, err := app.ListIssueNames(f, opt) + + if err != nil { + return nil, NewResolverError("IssueNamesBaseReolver", err.Error()) + } + + var pointerNames []*string + + for _, name := range names { + pointerNames = append(pointerNames, &name) + } + + filterItem := model.FilterItem{ + DisplayName: &FilterDisplayIssuePrimaryName, + Values: pointerNames, + } + + return &filterItem, nil +} diff --git a/internal/api/graphql/graph/baseResolver/issue_match.go b/internal/api/graphql/graph/baseResolver/issue_match.go index 68adaa82..9f582fab 100644 --- a/internal/api/graphql/graph/baseResolver/issue_match.go +++ b/internal/api/graphql/graph/baseResolver/issue_match.go @@ -92,7 +92,18 @@ func IssueMatchBaseResolver(app app.Heureka, ctx context.Context, filter *model. filter = &model.IssueMatchFilter{} } + issue_match_ids := []*int64{} + for _, issue_match_id := range filter.ID { + filterById, err := ParseCursor(issue_match_id) + if err != nil { + logrus.WithField("filter", filter).Error("IssueMatchBaseResolver: Error while parsing filter value 'id'") + return nil, NewResolverError("IssueMatchBaseResolver", "Bad Request - unable to parse filter, the value of the filter ID is invalid") + } + issue_match_ids = append(issue_match_ids, filterById) + } + f := &entity.IssueMatchFilter{ + Id: issue_match_ids, Paginated: entity.Paginated{First: first, After: afterId}, AffectedServiceName: filter.AffectedService, Status: lo.Map(filter.Status, func(item *model.IssueMatchStatusValues, _ int) *string { return pointer.String(item.String()) }), @@ -101,6 +112,10 @@ func IssueMatchBaseResolver(app app.Heureka, ctx context.Context, filter *model. IssueId: issueId, EvidenceId: eId, ComponentInstanceId: ciId, + Search: filter.Search, + ComponentName: filter.ComponentName, + PrimaryName: filter.PrimaryName, + IssueType: lo.Map(filter.IssueType, func(item *model.IssueTypes, _ int) *string { return pointer.String(item.String()) }), } opt := GetListOptions(requestedFields) @@ -133,5 +148,4 @@ func IssueMatchBaseResolver(app app.Heureka, ctx context.Context, filter *model. } return &connection, nil - } diff --git a/internal/api/graphql/graph/baseResolver/service.go b/internal/api/graphql/graph/baseResolver/service.go index 01513310..6210563c 100644 --- a/internal/api/graphql/graph/baseResolver/service.go +++ b/internal/api/graphql/graph/baseResolver/service.go @@ -175,8 +175,8 @@ func ServiceNameBaseResolver(app app.Heureka, ctx context.Context, filter *model } filterItem := model.FilterItem{ - FilterName: &FilterServiceName, - Values: pointerNames, + DisplayName: &FilterDisplayServiceName, + Values: pointerNames, } return &filterItem, nil diff --git a/internal/api/graphql/graph/baseResolver/support_group.go b/internal/api/graphql/graph/baseResolver/support_group.go index 738ed85d..e2318226 100644 --- a/internal/api/graphql/graph/baseResolver/support_group.go +++ b/internal/api/graphql/graph/baseResolver/support_group.go @@ -129,8 +129,8 @@ func SupportGroupNameBaseResolver(app app.Heureka, ctx context.Context, filter * } filterItem := model.FilterItem{ - FilterName: &FilterSupportGroupName, - Values: pointerNames, + DisplayName: &FilterDisplaySupportGroupName, + Values: pointerNames, } return &filterItem, nil diff --git a/internal/api/graphql/graph/baseResolver/user.go b/internal/api/graphql/graph/baseResolver/user.go index 715ad270..e0889010 100644 --- a/internal/api/graphql/graph/baseResolver/user.go +++ b/internal/api/graphql/graph/baseResolver/user.go @@ -157,8 +157,8 @@ func UserNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.Us } filterItem := model.FilterItem{ - FilterName: &FilterUserName, - Values: pointerNames, + DisplayName: &FilterDisplayUserName, + Values: pointerNames, } return &filterItem, nil @@ -195,8 +195,8 @@ func UniqueUserIDBaseResolver(app app.Heureka, ctx context.Context, filter *mode } filterItem := model.FilterItem{ - FilterName: &FilterUniqueUserID, - Values: pointerNames, + DisplayName: &FilterDisplayUniqueUserId, + Values: pointerNames, } return &filterItem, nil diff --git a/internal/api/graphql/graph/generated.go b/internal/api/graphql/graph/generated.go index 84d04a73..3429dbd1 100644 --- a/internal/api/graphql/graph/generated.go +++ b/internal/api/graphql/graph/generated.go @@ -50,6 +50,7 @@ type ResolverRoot interface { Issue() IssueResolver IssueMatch() IssueMatchResolver IssueMatchChange() IssueMatchChangeResolver + IssueMatchFilterValue() IssueMatchFilterValueResolver IssueRepository() IssueRepositoryResolver IssueVariant() IssueVariantResolver Mutation() MutationResolver @@ -217,8 +218,9 @@ type ComplexityRoot struct { } FilterItem struct { - FilterName func(childComplexity int) int - Values func(childComplexity int) int + DisplayName func(childComplexity int) int + FilterName func(childComplexity int) int + Values func(childComplexity int) int } Issue struct { @@ -297,6 +299,16 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + IssueMatchFilterValue struct { + AffectedService func(childComplexity int, filter *model.ServiceFilter) int + ComponentName func(childComplexity int, filter *model.ComponentFilter) int + IssueType func(childComplexity int) int + PrimaryName func(childComplexity int, filter *model.IssueFilter) int + Severity func(childComplexity int) int + Status func(childComplexity int) int + SupportGroupName func(childComplexity int, filter *model.SupportGroupFilter) int + } + IssueMetadata struct { ActivityCount func(childComplexity int) int ComponentInstanceCount func(childComplexity int) int @@ -432,20 +444,21 @@ type ComplexityRoot struct { } Query struct { - Activities func(childComplexity int, filter *model.ActivityFilter, first *int, after *string) int - ComponentInstances func(childComplexity int, filter *model.ComponentInstanceFilter, first *int, after *string) int - ComponentVersions func(childComplexity int, filter *model.ComponentVersionFilter, first *int, after *string) int - Components func(childComplexity int, filter *model.ComponentFilter, first *int, after *string) int - Evidences func(childComplexity int, filter *model.EvidenceFilter, first *int, after *string) int - IssueMatchChanges func(childComplexity int, filter *model.IssueMatchChangeFilter, first *int, after *string) int - IssueMatches func(childComplexity int, filter *model.IssueMatchFilter, first *int, after *string) int - IssueRepositories func(childComplexity int, filter *model.IssueRepositoryFilter, first *int, after *string) int - IssueVariants func(childComplexity int, filter *model.IssueVariantFilter, first *int, after *string) int - Issues func(childComplexity int, filter *model.IssueFilter, first *int, after *string) int - ServiceFilterValues func(childComplexity int) int - Services func(childComplexity int, filter *model.ServiceFilter, first *int, after *string) int - SupportGroups func(childComplexity int, filter *model.SupportGroupFilter, first *int, after *string) int - Users func(childComplexity int, filter *model.UserFilter, first *int, after *string) int + Activities func(childComplexity int, filter *model.ActivityFilter, first *int, after *string) int + ComponentInstances func(childComplexity int, filter *model.ComponentInstanceFilter, first *int, after *string) int + ComponentVersions func(childComplexity int, filter *model.ComponentVersionFilter, first *int, after *string) int + Components func(childComplexity int, filter *model.ComponentFilter, first *int, after *string) int + Evidences func(childComplexity int, filter *model.EvidenceFilter, first *int, after *string) int + IssueMatchChanges func(childComplexity int, filter *model.IssueMatchChangeFilter, first *int, after *string) int + IssueMatchFilterValues func(childComplexity int) int + IssueMatches func(childComplexity int, filter *model.IssueMatchFilter, first *int, after *string) int + IssueRepositories func(childComplexity int, filter *model.IssueRepositoryFilter, first *int, after *string) int + IssueVariants func(childComplexity int, filter *model.IssueVariantFilter, first *int, after *string) int + Issues func(childComplexity int, filter *model.IssueFilter, first *int, after *string) int + ServiceFilterValues func(childComplexity int) int + Services func(childComplexity int, filter *model.ServiceFilter, first *int, after *string) int + SupportGroups func(childComplexity int, filter *model.SupportGroupFilter, first *int, after *string) int + Users func(childComplexity int, filter *model.UserFilter, first *int, after *string) int } Service struct { @@ -569,6 +582,12 @@ type IssueMatchChangeResolver interface { Activity(ctx context.Context, obj *model.IssueMatchChange) (*model.Activity, error) } +type IssueMatchFilterValueResolver interface { + PrimaryName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.IssueFilter) (*model.FilterItem, error) + AffectedService(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) + ComponentName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ComponentFilter) (*model.FilterItem, error) + SupportGroupName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) +} type IssueRepositoryResolver interface { IssueVariants(ctx context.Context, obj *model.IssueRepository, filter *model.IssueVariantFilter, first *int, after *string) (*model.IssueVariantConnection, error) Services(ctx context.Context, obj *model.IssueRepository, filter *model.ServiceFilter, first *int, after *string) (*model.ServiceConnection, error) @@ -650,6 +669,7 @@ type QueryResolver interface { SupportGroups(ctx context.Context, filter *model.SupportGroupFilter, first *int, after *string) (*model.SupportGroupConnection, error) Users(ctx context.Context, filter *model.UserFilter, first *int, after *string) (*model.UserConnection, error) ServiceFilterValues(ctx context.Context) (*model.ServiceFilterValue, error) + IssueMatchFilterValues(ctx context.Context) (*model.IssueMatchFilterValue, error) } type ServiceResolver interface { Owners(ctx context.Context, obj *model.Service, filter *model.UserFilter, first *int, after *string) (*model.UserConnection, error) @@ -1381,6 +1401,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.EvidenceEdge.Node(childComplexity), true + case "FilterItem.displayName": + if e.complexity.FilterItem.DisplayName == nil { + break + } + + return e.complexity.FilterItem.DisplayName(childComplexity), true + case "FilterItem.filterName": if e.complexity.FilterItem.FilterName == nil { break @@ -1773,6 +1800,75 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueMatchEdge.Node(childComplexity), true + case "IssueMatchFilterValue.affectedService": + if e.complexity.IssueMatchFilterValue.AffectedService == nil { + break + } + + args, err := ec.field_IssueMatchFilterValue_affectedService_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.IssueMatchFilterValue.AffectedService(childComplexity, args["filter"].(*model.ServiceFilter)), true + + case "IssueMatchFilterValue.componentName": + if e.complexity.IssueMatchFilterValue.ComponentName == nil { + break + } + + args, err := ec.field_IssueMatchFilterValue_componentName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.IssueMatchFilterValue.ComponentName(childComplexity, args["filter"].(*model.ComponentFilter)), true + + case "IssueMatchFilterValue.issueType": + if e.complexity.IssueMatchFilterValue.IssueType == nil { + break + } + + return e.complexity.IssueMatchFilterValue.IssueType(childComplexity), true + + case "IssueMatchFilterValue.primaryName": + if e.complexity.IssueMatchFilterValue.PrimaryName == nil { + break + } + + args, err := ec.field_IssueMatchFilterValue_primaryName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.IssueMatchFilterValue.PrimaryName(childComplexity, args["filter"].(*model.IssueFilter)), true + + case "IssueMatchFilterValue.severity": + if e.complexity.IssueMatchFilterValue.Severity == nil { + break + } + + return e.complexity.IssueMatchFilterValue.Severity(childComplexity), true + + case "IssueMatchFilterValue.status": + if e.complexity.IssueMatchFilterValue.Status == nil { + break + } + + return e.complexity.IssueMatchFilterValue.Status(childComplexity), true + + case "IssueMatchFilterValue.supportGroupName": + if e.complexity.IssueMatchFilterValue.SupportGroupName == nil { + break + } + + args, err := ec.field_IssueMatchFilterValue_supportGroupName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.IssueMatchFilterValue.SupportGroupName(childComplexity, args["filter"].(*model.SupportGroupFilter)), true + case "IssueMetadata.activityCount": if e.complexity.IssueMetadata.ActivityCount == nil { break @@ -2858,6 +2954,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.IssueMatchChanges(childComplexity, args["filter"].(*model.IssueMatchChangeFilter), args["first"].(*int), args["after"].(*string)), true + case "Query.IssueMatchFilterValues": + if e.complexity.Query.IssueMatchFilterValues == nil { + break + } + + return e.complexity.Query.IssueMatchFilterValues(childComplexity), true + case "Query.IssueMatches": if e.complexity.Query.IssueMatches == nil { break @@ -3426,7 +3529,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } -//go:embed "schema/activity.graphqls" "schema/common.graphqls" "schema/component.graphqls" "schema/component_instance.graphqls" "schema/component_version.graphqls" "schema/evidence.graphqls" "schema/issue.graphqls" "schema/issue_match.graphqls" "schema/issue_match_change.graphqls" "schema/issue_repository.graphqls" "schema/issue_variant.graphqls" "schema/mutation.graphqls" "schema/query.graphqls" "schema/service.graphqls" "schema/service_filter.graphqls" "schema/support_group.graphqls" "schema/user.graphqls" +//go:embed "schema/activity.graphqls" "schema/common.graphqls" "schema/component.graphqls" "schema/component_instance.graphqls" "schema/component_version.graphqls" "schema/evidence.graphqls" "schema/issue.graphqls" "schema/issue_match.graphqls" "schema/issue_match_change.graphqls" "schema/issue_match_filter_value.graphqls" "schema/issue_repository.graphqls" "schema/issue_variant.graphqls" "schema/mutation.graphqls" "schema/query.graphqls" "schema/service.graphqls" "schema/service_filter.graphqls" "schema/support_group.graphqls" "schema/user.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { @@ -3447,6 +3550,7 @@ var sources = []*ast.Source{ {Name: "schema/issue.graphqls", Input: sourceData("schema/issue.graphqls"), BuiltIn: false}, {Name: "schema/issue_match.graphqls", Input: sourceData("schema/issue_match.graphqls"), BuiltIn: false}, {Name: "schema/issue_match_change.graphqls", Input: sourceData("schema/issue_match_change.graphqls"), BuiltIn: false}, + {Name: "schema/issue_match_filter_value.graphqls", Input: sourceData("schema/issue_match_filter_value.graphqls"), BuiltIn: false}, {Name: "schema/issue_repository.graphqls", Input: sourceData("schema/issue_repository.graphqls"), BuiltIn: false}, {Name: "schema/issue_variant.graphqls", Input: sourceData("schema/issue_variant.graphqls"), BuiltIn: false}, {Name: "schema/mutation.graphqls", Input: sourceData("schema/mutation.graphqls"), BuiltIn: false}, @@ -3741,6 +3845,66 @@ func (ec *executionContext) field_Evidence_issueMatches_args(ctx context.Context return args, nil } +func (ec *executionContext) field_IssueMatchFilterValue_affectedService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.ServiceFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOServiceFilter2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐServiceFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_IssueMatchFilterValue_componentName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.ComponentFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOComponentFilter2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐComponentFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_IssueMatchFilterValue_primaryName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.IssueFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOIssueFilter2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐIssueFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_IssueMatchFilterValue_supportGroupName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.SupportGroupFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalOSupportGroupFilter2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐSupportGroupFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + func (ec *executionContext) field_IssueMatch_effectiveIssueVariants_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -10284,6 +10448,47 @@ func (ec *executionContext) fieldContext_EvidenceEdge_cursor(_ context.Context, return fc, nil } +func (ec *executionContext) _FilterItem_displayName(ctx context.Context, field graphql.CollectedField, obj *model.FilterItem) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FilterItem_displayName(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.DisplayName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FilterItem_displayName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FilterItem", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _FilterItem_filterName(ctx context.Context, field graphql.CollectedField, obj *model.FilterItem) (ret graphql.Marshaler) { fc, err := ec.fieldContext_FilterItem_filterName(ctx, field) if err != nil { @@ -12815,8 +13020,8 @@ func (ec *executionContext) fieldContext_IssueMatchEdge_cursor(_ context.Context return fc, nil } -func (ec *executionContext) _IssueMetadata_serviceCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueMetadata_serviceCount(ctx, field) +func (ec *executionContext) _IssueMatchFilterValue_status(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_status(ctx, field) if err != nil { return graphql.Null } @@ -12829,38 +13034,43 @@ func (ec *executionContext) _IssueMetadata_serviceCount(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ServiceCount, nil + return obj.Status, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.FilterItem) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IssueMetadata_serviceCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IssueMatchFilterValue_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IssueMetadata", + Object: "IssueMatchFilterValue", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) }, } return fc, nil } -func (ec *executionContext) _IssueMetadata_activityCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueMetadata_activityCount(ctx, field) +func (ec *executionContext) _IssueMatchFilterValue_severity(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_severity(ctx, field) if err != nil { return graphql.Null } @@ -12873,38 +13083,43 @@ func (ec *executionContext) _IssueMetadata_activityCount(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ActivityCount, nil + return obj.Severity, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.FilterItem) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IssueMetadata_activityCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IssueMatchFilterValue_severity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IssueMetadata", + Object: "IssueMatchFilterValue", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) }, } return fc, nil } -func (ec *executionContext) _IssueMetadata_issueMatchCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueMetadata_issueMatchCount(ctx, field) +func (ec *executionContext) _IssueMatchFilterValue_issueType(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_issueType(ctx, field) if err != nil { return graphql.Null } @@ -12917,38 +13132,43 @@ func (ec *executionContext) _IssueMetadata_issueMatchCount(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IssueMatchCount, nil + return obj.IssueType, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.FilterItem) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IssueMetadata_issueMatchCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IssueMatchFilterValue_issueType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IssueMetadata", + Object: "IssueMatchFilterValue", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) }, } return fc, nil } -func (ec *executionContext) _IssueMetadata_componentInstanceCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueMetadata_componentInstanceCount(ctx, field) +func (ec *executionContext) _IssueMatchFilterValue_primaryName(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_primaryName(ctx, field) if err != nil { return graphql.Null } @@ -12961,38 +13181,54 @@ func (ec *executionContext) _IssueMetadata_componentInstanceCount(ctx context.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ComponentInstanceCount, nil + return ec.resolvers.IssueMatchFilterValue().PrimaryName(rctx, obj, fc.Args["filter"].(*model.IssueFilter)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.FilterItem) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IssueMetadata_componentInstanceCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IssueMatchFilterValue_primaryName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IssueMetadata", + Object: "IssueMatchFilterValue", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_IssueMatchFilterValue_primaryName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _IssueMetadata_componentVersionCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueMetadata_componentVersionCount(ctx, field) +func (ec *executionContext) _IssueMatchFilterValue_affectedService(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_affectedService(ctx, field) if err != nil { return graphql.Null } @@ -13005,21 +13241,377 @@ func (ec *executionContext) _IssueMetadata_componentVersionCount(ctx context.Con }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ComponentVersionCount, nil + return ec.resolvers.IssueMatchFilterValue().AffectedService(rctx, obj, fc.Args["filter"].(*model.ServiceFilter)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*model.FilterItem) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMatchFilterValue_affectedService(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMatchFilterValue", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_IssueMatchFilterValue_affectedService_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _IssueMatchFilterValue_componentName(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_componentName(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 ec.resolvers.IssueMatchFilterValue().ComponentName(rctx, obj, fc.Args["filter"].(*model.ComponentFilter)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.FilterItem) + fc.Result = res + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMatchFilterValue_componentName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMatchFilterValue", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_IssueMatchFilterValue_componentName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _IssueMatchFilterValue_supportGroupName(ctx context.Context, field graphql.CollectedField, obj *model.IssueMatchFilterValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMatchFilterValue_supportGroupName(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 ec.resolvers.IssueMatchFilterValue().SupportGroupName(rctx, obj, fc.Args["filter"].(*model.SupportGroupFilter)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.FilterItem) + fc.Result = res + return ec.marshalOFilterItem2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐFilterItem(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMatchFilterValue_supportGroupName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMatchFilterValue", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) + case "filterName": + return ec.fieldContext_FilterItem_filterName(ctx, field) + case "values": + return ec.fieldContext_FilterItem_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FilterItem", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_IssueMatchFilterValue_supportGroupName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _IssueMetadata_serviceCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMetadata_serviceCount(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.ServiceCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMetadata_serviceCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMetadata", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IssueMetadata_activityCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMetadata_activityCount(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.ActivityCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMetadata_activityCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMetadata", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IssueMetadata_issueMatchCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMetadata_issueMatchCount(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.IssueMatchCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMetadata_issueMatchCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMetadata", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IssueMetadata_componentInstanceCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMetadata_componentInstanceCount(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.ComponentInstanceCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IssueMetadata_componentInstanceCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IssueMetadata", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IssueMetadata_componentVersionCount(ctx context.Context, field graphql.CollectedField, obj *model.IssueMetadata) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueMetadata_componentVersionCount(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.ComponentVersionCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_IssueMetadata_componentVersionCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -19563,25 +20155,76 @@ func (ec *executionContext) fieldContext_Query_Users(ctx context.Context, field case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_Users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_ServiceFilterValues(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_ServiceFilterValues(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 ec.resolvers.Query().ServiceFilterValues(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.ServiceFilterValue) + fc.Result = res + return ec.marshalOServiceFilterValue2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐServiceFilterValue(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_ServiceFilterValues(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "serviceName": + return ec.fieldContext_ServiceFilterValue_serviceName(ctx, field) + case "uniqueUserId": + return ec.fieldContext_ServiceFilterValue_uniqueUserId(ctx, field) + case "userName": + return ec.fieldContext_ServiceFilterValue_userName(ctx, field) + case "supportGroupName": + return ec.fieldContext_ServiceFilterValue_supportGroupName(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ServiceFilterValue", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_Users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_ServiceFilterValues(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_ServiceFilterValues(ctx, field) +func (ec *executionContext) _Query_IssueMatchFilterValues(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_IssueMatchFilterValues(ctx, field) if err != nil { return graphql.Null } @@ -19594,7 +20237,7 @@ func (ec *executionContext) _Query_ServiceFilterValues(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ServiceFilterValues(rctx) + return ec.resolvers.Query().IssueMatchFilterValues(rctx) }) if err != nil { ec.Error(ctx, err) @@ -19603,12 +20246,12 @@ func (ec *executionContext) _Query_ServiceFilterValues(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.(*model.ServiceFilterValue) + res := resTmp.(*model.IssueMatchFilterValue) fc.Result = res - return ec.marshalOServiceFilterValue2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐServiceFilterValue(ctx, field.Selections, res) + return ec.marshalOIssueMatchFilterValue2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐIssueMatchFilterValue(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_ServiceFilterValues(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_IssueMatchFilterValues(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -19616,16 +20259,22 @@ func (ec *executionContext) fieldContext_Query_ServiceFilterValues(_ context.Con IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "serviceName": - return ec.fieldContext_ServiceFilterValue_serviceName(ctx, field) - case "uniqueUserId": - return ec.fieldContext_ServiceFilterValue_uniqueUserId(ctx, field) - case "userName": - return ec.fieldContext_ServiceFilterValue_userName(ctx, field) + case "status": + return ec.fieldContext_IssueMatchFilterValue_status(ctx, field) + case "severity": + return ec.fieldContext_IssueMatchFilterValue_severity(ctx, field) + case "issueType": + return ec.fieldContext_IssueMatchFilterValue_issueType(ctx, field) + case "primaryName": + return ec.fieldContext_IssueMatchFilterValue_primaryName(ctx, field) + case "affectedService": + return ec.fieldContext_IssueMatchFilterValue_affectedService(ctx, field) + case "componentName": + return ec.fieldContext_IssueMatchFilterValue_componentName(ctx, field) case "supportGroupName": - return ec.fieldContext_ServiceFilterValue_supportGroupName(ctx, field) + return ec.fieldContext_IssueMatchFilterValue_supportGroupName(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ServiceFilterValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type IssueMatchFilterValue", field.Name) }, } return fc, nil @@ -20471,6 +21120,8 @@ func (ec *executionContext) fieldContext_ServiceFilterValue_serviceName(ctx cont IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) case "filterName": return ec.fieldContext_FilterItem_filterName(ctx, field) case "values": @@ -20529,6 +21180,8 @@ func (ec *executionContext) fieldContext_ServiceFilterValue_uniqueUserId(ctx con IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) case "filterName": return ec.fieldContext_FilterItem_filterName(ctx, field) case "values": @@ -20587,6 +21240,8 @@ func (ec *executionContext) fieldContext_ServiceFilterValue_userName(ctx context IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) case "filterName": return ec.fieldContext_FilterItem_filterName(ctx, field) case "values": @@ -20645,6 +21300,8 @@ func (ec *executionContext) fieldContext_ServiceFilterValue_supportGroupName(ctx IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "displayName": + return ec.fieldContext_FilterItem_displayName(ctx, field) case "filterName": return ec.fieldContext_FilterItem_filterName(ctx, field) case "values": @@ -24120,13 +24777,48 @@ func (ec *executionContext) unmarshalInputIssueMatchFilter(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"status", "severity", "affectedService", "SupportGroupName"} + fieldsInOrder := [...]string{"id", "search", "primaryName", "componentName", "issueType", "status", "severity", "affectedService", "supportGroupName"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "search": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("search")) + data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Search = data + case "primaryName": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryName")) + data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrimaryName = data + case "componentName": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("componentName")) + data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ComponentName = data + case "issueType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("issueType")) + data, err := ec.unmarshalOIssueTypes2ᚕᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐIssueTypes(ctx, v) + if err != nil { + return it, err + } + it.IssueType = data case "status": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) data, err := ec.unmarshalOIssueMatchStatusValues2ᚕᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐIssueMatchStatusValues(ctx, v) @@ -24148,8 +24840,8 @@ func (ec *executionContext) unmarshalInputIssueMatchFilter(ctx context.Context, return it, err } it.AffectedService = data - case "SupportGroupName": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("SupportGroupName")) + case "supportGroupName": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportGroupName")) data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) if err != nil { return it, err @@ -26307,6 +26999,8 @@ func (ec *executionContext) _FilterItem(ctx context.Context, sel ast.SelectionSe switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FilterItem") + case "displayName": + out.Values[i] = ec._FilterItem_displayName(ctx, field, obj) case "filterName": out.Values[i] = ec._FilterItem_filterName(ctx, field, obj) case "values": @@ -27161,6 +27855,178 @@ func (ec *executionContext) _IssueMatchEdge(ctx context.Context, sel ast.Selecti return out } +var issueMatchFilterValueImplementors = []string{"IssueMatchFilterValue"} + +func (ec *executionContext) _IssueMatchFilterValue(ctx context.Context, sel ast.SelectionSet, obj *model.IssueMatchFilterValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, issueMatchFilterValueImplementors) + + 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("IssueMatchFilterValue") + case "status": + out.Values[i] = ec._IssueMatchFilterValue_status(ctx, field, obj) + case "severity": + out.Values[i] = ec._IssueMatchFilterValue_severity(ctx, field, obj) + case "issueType": + out.Values[i] = ec._IssueMatchFilterValue_issueType(ctx, field, obj) + case "primaryName": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._IssueMatchFilterValue_primaryName(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "affectedService": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._IssueMatchFilterValue_affectedService(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "componentName": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._IssueMatchFilterValue_componentName(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "supportGroupName": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._IssueMatchFilterValue_supportGroupName(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + 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 issueMetadataImplementors = []string{"IssueMetadata"} func (ec *executionContext) _IssueMetadata(ctx context.Context, sel ast.SelectionSet, obj *model.IssueMetadata) graphql.Marshaler { @@ -28439,6 +29305,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "IssueMatchFilterValues": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_IssueMatchFilterValues(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -31125,6 +32010,13 @@ func (ec *executionContext) unmarshalOIssueMatchFilter2ᚖgithubᚗwdfᚗsapᚗc return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOIssueMatchFilterValue2ᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐIssueMatchFilterValue(ctx context.Context, sel ast.SelectionSet, v *model.IssueMatchFilterValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._IssueMatchFilterValue(ctx, sel, v) +} + func (ec *executionContext) unmarshalOIssueMatchStatusValues2ᚕᚖgithubᚗwdfᚗsapᚗcorpᚋccᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐIssueMatchStatusValues(ctx context.Context, v interface{}) ([]*model.IssueMatchStatusValues, error) { if v == nil { return nil, nil diff --git a/internal/api/graphql/graph/model/models_gen.go b/internal/api/graphql/graph/model/models_gen.go index 0f135e17..0d3d46a8 100644 --- a/internal/api/graphql/graph/model/models_gen.go +++ b/internal/api/graphql/graph/model/models_gen.go @@ -3,7 +3,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package model import ( @@ -294,8 +293,9 @@ type EvidenceInput struct { } type FilterItem struct { - FilterName *string `json:"filterName,omitempty"` - Values []*string `json:"values,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + FilterName *string `json:"filterName,omitempty"` + Values []*string `json:"values,omitempty"` } type Issue struct { @@ -433,10 +433,25 @@ func (this IssueMatchEdge) GetNode() Node { return *this.Node } func (this IssueMatchEdge) GetCursor() *string { return this.Cursor } type IssueMatchFilter struct { + ID []*string `json:"id,omitempty"` + Search []*string `json:"search,omitempty"` + PrimaryName []*string `json:"primaryName,omitempty"` + ComponentName []*string `json:"componentName,omitempty"` + IssueType []*IssueTypes `json:"issueType,omitempty"` Status []*IssueMatchStatusValues `json:"status,omitempty"` Severity []*SeverityValues `json:"severity,omitempty"` AffectedService []*string `json:"affectedService,omitempty"` - SupportGroupName []*string `json:"SupportGroupName,omitempty"` + SupportGroupName []*string `json:"supportGroupName,omitempty"` +} + +type IssueMatchFilterValue struct { + Status *FilterItem `json:"status,omitempty"` + Severity *FilterItem `json:"severity,omitempty"` + IssueType *FilterItem `json:"issueType,omitempty"` + PrimaryName *FilterItem `json:"primaryName,omitempty"` + AffectedService *FilterItem `json:"affectedService,omitempty"` + ComponentName *FilterItem `json:"componentName,omitempty"` + SupportGroupName *FilterItem `json:"supportGroupName,omitempty"` } type IssueMatchInput struct { diff --git a/internal/api/graphql/graph/resolver/issue_match_filter_value.go b/internal/api/graphql/graph/resolver/issue_match_filter_value.go new file mode 100644 index 00000000..eeb2d900 --- /dev/null +++ b/internal/api/graphql/graph/resolver/issue_match_filter_value.go @@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +// SPDX-License-Identifier: Apache-2.0 + +package resolver + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.49 + +import ( + "context" + + "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph" + "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph/baseResolver" + "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph/model" +) + +// PrimaryName is the resolver for the primaryName field. +func (r *issueMatchFilterValueResolver) PrimaryName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.IssueFilter) (*model.FilterItem, error) { + item, err := baseResolver.IssueNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.IssueMatchFilterPrimaryName + return item, nil +} + +// AffectedService is the resolver for the affectedService field. +func (r *issueMatchFilterValueResolver) AffectedService(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { + item, err := baseResolver.ServiceNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.IssueMatchFilterAffectedService + return item, nil +} + +// ComponentName is the resolver for the componentName field. +func (r *issueMatchFilterValueResolver) ComponentName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ComponentFilter) (*model.FilterItem, error) { + item, err := baseResolver.ComponentNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.IssueMatchFilterComponentName + return item, nil +} + +// SupportGroupName is the resolver for the supportGroupName field. +func (r *issueMatchFilterValueResolver) SupportGroupName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { + item, err := baseResolver.SupportGroupNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.IssueMatchFilterSupportGroupName + return item, nil +} + +// IssueMatchFilterValue returns graph.IssueMatchFilterValueResolver implementation. +func (r *Resolver) IssueMatchFilterValue() graph.IssueMatchFilterValueResolver { + return &issueMatchFilterValueResolver{r} +} + +type issueMatchFilterValueResolver struct{ *Resolver } diff --git a/internal/api/graphql/graph/resolver/query.go b/internal/api/graphql/graph/resolver/query.go index 7ac95015..7177d43b 100644 --- a/internal/api/graphql/graph/resolver/query.go +++ b/internal/api/graphql/graph/resolver/query.go @@ -10,9 +10,11 @@ package resolver import ( "context" + "github.com/samber/lo" "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph" "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph/baseResolver" "github.wdf.sap.corp/cc/heureka/internal/api/graphql/graph/model" + "k8s.io/utils/pointer" ) // Issues is the resolver for the Issues field. @@ -85,6 +87,27 @@ func (r *queryResolver) ServiceFilterValues(ctx context.Context) (*model.Service return &model.ServiceFilterValue{}, nil } +// IssueMatchFilterValues is the resolver for the IssueMatchFilterValues field. +func (r *queryResolver) IssueMatchFilterValues(ctx context.Context) (*model.IssueMatchFilterValue, error) { + return &model.IssueMatchFilterValue{ + Status: &model.FilterItem{ + DisplayName: &baseResolver.FilterDisplayIssueMatchStatus, + FilterName: &baseResolver.IssueMatchFilterStatus, + Values: lo.Map(model.AllSeverityValues, func(item model.SeverityValues, _ int) *string { return pointer.String(item.String()) }), + }, + IssueType: &model.FilterItem{ + DisplayName: &baseResolver.FilterDisplayIssueType, + FilterName: &baseResolver.IssueMatchFilterIssueType, + Values: lo.Map(model.AllIssueTypes, func(item model.IssueTypes, _ int) *string { return pointer.String(item.String()) }), + }, + Severity: &model.FilterItem{ + DisplayName: &baseResolver.FilterDisplayIssueSeverity, + FilterName: &baseResolver.IssueMatchFilterSeverity, + Values: lo.Map(model.AllIssueMatchStatusValues, func(item model.IssueMatchStatusValues, _ int) *string { return pointer.String(item.String()) }), + }, + }, nil +} + // Query returns graph.QueryResolver implementation. func (r *Resolver) Query() graph.QueryResolver { return &queryResolver{r} } diff --git a/internal/api/graphql/graph/resolver/service_filter.go b/internal/api/graphql/graph/resolver/service_filter.go index d6bce260..8437ba9f 100644 --- a/internal/api/graphql/graph/resolver/service_filter.go +++ b/internal/api/graphql/graph/resolver/service_filter.go @@ -17,22 +17,42 @@ import ( // ServiceName is the resolver for the serviceName field. func (r *serviceFilterValueResolver) ServiceName(ctx context.Context, obj *model.ServiceFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { - return baseResolver.ServiceNameBaseResolver(r.App, ctx, filter) + item, err := baseResolver.ServiceNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.ServiceFilterServiceName + return item, nil } // UniqueUserID is the resolver for the uniqueUserId field. func (r *serviceFilterValueResolver) UniqueUserID(ctx context.Context, obj *model.ServiceFilterValue, filter *model.UserFilter) (*model.FilterItem, error) { - return baseResolver.UniqueUserIDBaseResolver(r.App, ctx, filter) + item, err := baseResolver.UniqueUserIDBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.ServiceFilterUniqueUserId + return item, err } // UserName is the resolver for the userName field. func (r *serviceFilterValueResolver) UserName(ctx context.Context, obj *model.ServiceFilterValue, filter *model.UserFilter) (*model.FilterItem, error) { - return baseResolver.UserNameBaseResolver(r.App, ctx, filter) + item, err := baseResolver.UserNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.ServiceFilterUserName + return item, err } // SupportGroupName is the resolver for the supportGroupName field. func (r *serviceFilterValueResolver) SupportGroupName(ctx context.Context, obj *model.ServiceFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { - return baseResolver.SupportGroupNameBaseResolver(r.App, ctx, filter) + item, err := baseResolver.SupportGroupNameBaseResolver(r.App, ctx, filter) + if err != nil { + return nil, err + } + item.FilterName = &baseResolver.ServiceFilterSupportGroupName + return item, err } // ServiceFilterValue returns graph.ServiceFilterValueResolver implementation. diff --git a/internal/api/graphql/graph/schema/common.graphqls b/internal/api/graphql/graph/schema/common.graphqls index 92f9ab56..9a97275c 100644 --- a/internal/api/graphql/graph/schema/common.graphqls +++ b/internal/api/graphql/graph/schema/common.graphqls @@ -101,6 +101,7 @@ input SeverityInput { } type FilterItem { + displayName: String filterName: String values: [String] } \ No newline at end of file diff --git a/internal/api/graphql/graph/schema/issue_match.graphqls b/internal/api/graphql/graph/schema/issue_match.graphqls index 251af764..479a82f8 100644 --- a/internal/api/graphql/graph/schema/issue_match.graphqls +++ b/internal/api/graphql/graph/schema/issue_match.graphqls @@ -30,10 +30,15 @@ input IssueMatchInput { } input IssueMatchFilter { + id: [String] + search: [String] + primaryName: [String] + componentName: [String] + issueType: [IssueTypes] status: [IssueMatchStatusValues] severity: [SeverityValues] affectedService: [String] - SupportGroupName: [String] + supportGroupName: [String] } #type CCloudSeverity { diff --git a/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls b/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls new file mode 100644 index 00000000..5387d840 --- /dev/null +++ b/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors +# SPDX-License-Identifier: Apache-2.0 + +type IssueMatchFilterValue { + status: FilterItem + severity: FilterItem + issueType: FilterItem + primaryName(filter: IssueFilter): FilterItem + affectedService(filter: ServiceFilter): FilterItem + componentName(filter: ComponentFilter): FilterItem + supportGroupName(filter: SupportGroupFilter): FilterItem +} \ No newline at end of file diff --git a/internal/api/graphql/graph/schema/query.graphqls b/internal/api/graphql/graph/schema/query.graphqls index caa20b3d..abf38753 100644 --- a/internal/api/graphql/graph/schema/query.graphqls +++ b/internal/api/graphql/graph/schema/query.graphqls @@ -16,4 +16,5 @@ type Query { SupportGroups(filter: SupportGroupFilter, first: Int, after: String): SupportGroupConnection Users(filter: UserFilter, first: Int, after: String): UserConnection ServiceFilterValues: ServiceFilterValue + IssueMatchFilterValues: IssueMatchFilterValue } \ No newline at end of file diff --git a/internal/app/component.go b/internal/app/component.go index f818208b..a2059c96 100644 --- a/internal/app/component.go +++ b/internal/app/component.go @@ -147,3 +147,19 @@ func (h *HeurekaApp) DeleteComponent(id int64) error { return nil } + +func (h *HeurekaApp) ListComponentNames(filter *entity.ComponentFilter, options *entity.ListOptions) ([]string, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.ListComponentNames", + "filter": filter, + }) + + componentNames, err := h.database.GetComponentNames(filter) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while retrieving componentNames.") + } + + return componentNames, nil +} diff --git a/internal/app/interface.go b/internal/app/interface.go index 940645b5..76328563 100644 --- a/internal/app/interface.go +++ b/internal/app/interface.go @@ -14,6 +14,7 @@ type Heureka interface { DeleteIssue(int64) error AddComponentVersionToIssue(int64, int64) (*entity.Issue, error) RemoveComponentVersionFromIssue(int64, int64) (*entity.Issue, error) + ListIssueNames(*entity.IssueFilter, *entity.ListOptions) ([]string, error) ListIssueVariants(*entity.IssueVariantFilter, *entity.ListOptions) (*entity.List[entity.IssueVariantResult], error) ListEffectiveIssueVariants(*entity.IssueVariantFilter, *entity.ListOptions) (*entity.List[entity.IssueVariantResult], error) @@ -72,6 +73,7 @@ type Heureka interface { CreateComponentInstance(*entity.ComponentInstance) (*entity.ComponentInstance, error) UpdateComponentInstance(*entity.ComponentInstance) (*entity.ComponentInstance, error) DeleteComponentInstance(int64) error + ListComponentNames(*entity.ComponentFilter, *entity.ListOptions) ([]string, error) ListActivities(*entity.ActivityFilter, *entity.ListOptions) (*entity.List[entity.ActivityResult], error) GetActivity(int64) (*entity.Activity, error) diff --git a/internal/app/issue.go b/internal/app/issue.go index 21bc0ad2..a312706e 100644 --- a/internal/app/issue.go +++ b/internal/app/issue.go @@ -233,3 +233,19 @@ func (h *HeurekaApp) RemoveComponentVersionFromIssue(issueId, componentVersionId return h.GetIssue(issueId) } + +func (h *HeurekaApp) ListIssueNames(filter *entity.IssueFilter, options *entity.ListOptions) ([]string, error) { + l := logrus.WithFields(logrus.Fields{ + "event": "app.ListIssueNames", + "filter": filter, + }) + + issueNames, err := h.database.GetIssueNames(filter) + + if err != nil { + l.Error(err) + return nil, heurekaError("Internal error while retrieving issueNames.") + } + + return issueNames, nil +} diff --git a/internal/database/interface.go b/internal/database/interface.go index 8ce5124d..78b52dd8 100644 --- a/internal/database/interface.go +++ b/internal/database/interface.go @@ -16,6 +16,7 @@ type Database interface { DeleteIssue(int64) error AddComponentVersionToIssue(int64, int64) error RemoveComponentVersionFromIssue(int64, int64) error + GetIssueNames(*entity.IssueFilter) ([]string, error) GetIssueVariants(*entity.IssueVariantFilter) ([]entity.IssueVariant, error) GetAllIssueVariantIds(*entity.IssueVariantFilter) ([]int64, error) @@ -86,6 +87,7 @@ type Database interface { CreateComponentInstance(*entity.ComponentInstance) (*entity.ComponentInstance, error) UpdateComponentInstance(*entity.ComponentInstance) error DeleteComponentInstance(int64) error + GetComponentNames(filter *entity.ComponentFilter) ([]string, error) GetActivities(*entity.ActivityFilter) ([]entity.Activity, error) GetAllActivityIds(*entity.ActivityFilter) ([]int64, error) diff --git a/internal/database/mariadb/component.go b/internal/database/mariadb/component.go index f9e897de..73489c19 100644 --- a/internal/database/mariadb/component.go +++ b/internal/database/mariadb/component.go @@ -267,3 +267,52 @@ func (s *SqlDatabase) DeleteComponent(id int64) error { return err } + +func (s *SqlDatabase) GetComponentNames(filter *entity.ComponentFilter) ([]string, error) { + l := logrus.WithFields(logrus.Fields{ + "filter": filter, + "event": "database.GetComponentNames", + }) + + baseQuery := ` + SELECT C.component_name FROM Component C + %s + %s + ` + + // Ensure the filter is initialized + filter = s.ensureComponentFilter(filter) + + // Builds full statement with possible joins and filters + stmt, filterParameters, err := s.buildComponentStatement(baseQuery, filter, false, l) + if err != nil { + l.Error("Error preparing statement: ", err) + return nil, err + } + defer stmt.Close() + + // Execute the query + rows, err := stmt.Queryx(filterParameters...) + if err != nil { + l.Error("Error executing query: ", err) + return nil, err + } + defer rows.Close() + + // Collect the results + componentNames := []string{} + var name string + for rows.Next() { + if err := rows.Scan(&name); err != nil { + l.Error("Error scanning row: ", err) + continue + } + componentNames = append(componentNames, name) + } + if err = rows.Err(); err != nil { + l.Error("Row iteration error: ", err) + return nil, err + } + + return componentNames, nil +} diff --git a/internal/database/mariadb/issue.go b/internal/database/mariadb/issue.go index 620bd546..44b8246c 100644 --- a/internal/database/mariadb/issue.go +++ b/internal/database/mariadb/issue.go @@ -476,3 +476,52 @@ func (s *SqlDatabase) RemoveComponentVersionFromIssue(issueId int64, componentVe return err } + +func (s *SqlDatabase) GetIssueNames(filter *entity.IssueFilter) ([]string, error) { + l := logrus.WithFields(logrus.Fields{ + "filter": filter, + "event": "database.GetIssueNames", + }) + + baseQuery := ` + SELECT I.issue_primary_name FROM Issue I + %s + %s + ` + + // Ensure the filter is initialized + filter = s.ensureIssueFilter(filter) + + // Builds full statement with possible joins and filters + stmt, filterParameters, err := s.buildIssueStatement(baseQuery, filter, []string{}, false, l) + if err != nil { + l.Error("Error preparing statement: ", err) + return nil, err + } + defer stmt.Close() + + // Execute the query + rows, err := stmt.Queryx(filterParameters...) + if err != nil { + l.Error("Error executing query: ", err) + return nil, err + } + defer rows.Close() + + // Collect the results + issueNames := []string{} + var name string + for rows.Next() { + if err := rows.Scan(&name); err != nil { + l.Error("Error scanning row: ", err) + continue + } + issueNames = append(issueNames, name) + } + if err = rows.Err(); err != nil { + l.Error("Row iteration error: ", err) + return nil, err + } + + return issueNames, nil +} diff --git a/internal/database/mariadb/issue_match.go b/internal/database/mariadb/issue_match.go index 2bd47b2c..ab2aa5a0 100644 --- a/internal/database/mariadb/issue_match.go +++ b/internal/database/mariadb/issue_match.go @@ -38,6 +38,10 @@ func (s *SqlDatabase) getIssueMatchFilterString(filter *entity.IssueMatchFilter) fl = append(fl, buildFilterQuery(filter.SeverityValue, "IM.issuematch_rating = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Status, "IM.issuematch_status = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.SupportGroupName, "SG.supportgroup_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.PrimaryName, "I.issue_primary_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.ComponentName, "C.component_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.IssueType, "I.issue_type = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.Search, wildCardFilterQuery, OP_OR)) fl = append(fl, "IM.issuematch_deleted_at IS NULL") return combineFilterQueries(fl, OP_AND) @@ -45,22 +49,49 @@ func (s *SqlDatabase) getIssueMatchFilterString(filter *entity.IssueMatchFilter) func (s *SqlDatabase) getIssueMatchJoins(filter *entity.IssueMatchFilter) string { joins := "" + + if len(filter.Search) > 0 || len(filter.IssueType) > 0 || len(filter.PrimaryName) > 0 { + joins = fmt.Sprintf("%s\n%s", joins, ` + LEFT JOIN Issue I on I.issue_id = IM.issuematch_issue_id + `) + if len(filter.Search) > 0 { + joins = fmt.Sprintf("%s\n%s", joins, ` + LEFT JOIN IssueVariant IV on IV.issuevariant_issue_id = I.issue_id + `) + } + } + if len(filter.EvidenceId) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN IssueMatchEvidence IME on IME.issuematchevidence_issue_match_id = IM.issuematch_id `) } - if len(filter.AffectedServiceName) > 0 || len(filter.SupportGroupName) > 0 { + + if len(filter.AffectedServiceName) > 0 || len(filter.SupportGroupName) > 0 || len(filter.ComponentName) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN ComponentInstance CI on CI.componentinstance_id = IM.issuematch_component_instance_id - LEFT JOIN Service S on S.service_id = CI.componentinstance_service_id + `) - } - if len(filter.SupportGroupName) > 0 { - joins = fmt.Sprintf("%s\n%s", joins, ` + + if len(filter.ComponentName) > 0 { + joins = fmt.Sprintf("%s\n%s", joins, ` + LEFT JOIN ComponentVersion CV on CV.componentversion_id = CI.componentinstance_component_version_id + LEFT JOIN Component C on C.component_id = CV.componentversion_component_id + `) + } + + if len(filter.AffectedServiceName) > 0 || len(filter.SupportGroupName) > 0 { + joins = fmt.Sprintf("%s\n%s", joins, ` + LEFT JOIN Service S on S.service_id = CI.componentinstance_service_id + `) + } + + if len(filter.SupportGroupName) > 0 { + joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN SupportGroupService SGS on S.service_id = SGS.supportgroupservice_service_id LEFT JOIN SupportGroup SG on SG.supportgroup_id = SGS.supportgroupservice_support_group_id `) + } } return joins } @@ -94,39 +125,44 @@ func (s *SqlDatabase) getIssueMatchUpdateFields(issueMatch *entity.IssueMatch) s return strings.Join(fl, ", ") } -func (s *SqlDatabase) GetAllIssueMatchIds(filter *entity.IssueMatchFilter) ([]int64, error) { - +func (s *SqlDatabase) buildIssueMatchStatement(baseQuery string, filter *entity.IssueMatchFilter, withCursor bool, l *logrus.Entry) (*sqlx.Stmt, []interface{}, error) { + var query string filter = s.ensureIssueMatchFilter(filter) - l := logrus.WithFields(logrus.Fields{ - "filter": filter, - "event": "database.GetIssueMatches", - }) - - baseQuery := ` - SELECT IM.issuematch_id FROM IssueMatch IM - %s - %s GROUP BY IM.issuematch_id ORDER BY IM.issuematch_id - ` + l.WithFields(logrus.Fields{"filter": filter}) filterStr := s.getIssueMatchFilterString(filter) - if filterStr != "" { - filterStr = fmt.Sprintf("WHERE %s", filterStr) - } joins := s.getIssueMatchJoins(filter) + cursor := getCursor(filter.Paginated, filterStr, "IM.issuematch_id > ?") + + whereClause := "" + if filterStr != "" || withCursor { + whereClause = fmt.Sprintf("WHERE %s", filterStr) + } - query := fmt.Sprintf(baseQuery, joins, filterStr) - stmt, err := s.db.Preparex(query) + // construct final query + if withCursor { + query = fmt.Sprintf(baseQuery, joins, whereClause, cursor.Statement) + } else { + query = fmt.Sprintf(baseQuery, joins, whereClause) + } + + //construct prepared statement and if where clause does exist add parameters + var stmt *sqlx.Stmt + var err error + + stmt, err = s.db.Preparex(query) if err != nil { - msg := "Error while preparing Statement" + msg := ERROR_MSG_PREPARED_STMT l.WithFields( logrus.Fields{ "error": err, "query": query, + "stmt": stmt, }).Error(msg) - return nil, fmt.Errorf("%s", msg) + return nil, nil, fmt.Errorf("%s", msg) } - defer stmt.Close() + //adding parameters var filterParameters []interface{} filterParameters = buildQueryParameters(filterParameters, filter.Id) filterParameters = buildQueryParameters(filterParameters, filter.IssueId) @@ -136,12 +172,41 @@ func (s *SqlDatabase) GetAllIssueMatchIds(filter *entity.IssueMatchFilter) ([]in filterParameters = buildQueryParameters(filterParameters, filter.SeverityValue) filterParameters = buildQueryParameters(filterParameters, filter.Status) filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupName) + filterParameters = buildQueryParameters(filterParameters, filter.PrimaryName) + filterParameters = buildQueryParameters(filterParameters, filter.ComponentName) + filterParameters = buildQueryParameters(filterParameters, filter.IssueType) + filterParameters = buildQueryParametersCount(filterParameters, filter.Search, wildCardFilterParamCount) + + if withCursor { + filterParameters = append(filterParameters, cursor.Value) + filterParameters = append(filterParameters, cursor.Limit) + } + + return stmt, filterParameters, nil +} + +func (s *SqlDatabase) GetAllIssueMatchIds(filter *entity.IssueMatchFilter) ([]int64, error) { + l := logrus.WithFields(logrus.Fields{ + "filter": filter, + "event": "database.GetIssueMatches", + }) + + baseQuery := ` + SELECT IM.issuematch_id FROM IssueMatch IM + %s + %s GROUP BY IM.issuematch_id ORDER BY IM.issuematch_id + ` + + stmt, filterParameters, err := s.buildIssueMatchStatement(baseQuery, filter, false, l) + + if err != nil { + return nil, err + } return performIdScan(stmt, filterParameters, l) } func (s *SqlDatabase) GetIssueMatches(filter *entity.IssueMatchFilter) ([]entity.IssueMatch, error) { - filter = s.ensureIssueMatchFilter(filter) l := logrus.WithFields(logrus.Fields{ "filter": filter, "event": "database.GetIssueMatches", @@ -150,37 +215,14 @@ func (s *SqlDatabase) GetIssueMatches(filter *entity.IssueMatchFilter) ([]entity baseQuery := ` SELECT IM.* FROM IssueMatch IM %s - WHERE %s %s GROUP BY IM.issuematch_id ORDER BY IM.issuematch_id LIMIT ? + %s %s GROUP BY IM.issuematch_id ORDER BY IM.issuematch_id LIMIT ? ` - filterStr := s.getIssueMatchFilterString(filter) - joins := s.getIssueMatchJoins(filter) - cursor := getCursor(filter.Paginated, filterStr, "IM.issuematch_id > ?") + stmt, filterParameters, err := s.buildIssueMatchStatement(baseQuery, filter, true, l) - query := fmt.Sprintf(baseQuery, joins, filterStr, cursor.Statement) - stmt, err := s.db.Preparex(query) if err != nil { - msg := "Error while preparing Statement" - l.WithFields( - logrus.Fields{ - "error": err, - "query": query, - }).Error(msg) - return nil, fmt.Errorf("%s", msg) + return nil, err } - defer stmt.Close() - - var filterParameters []interface{} - filterParameters = buildQueryParameters(filterParameters, filter.Id) - filterParameters = buildQueryParameters(filterParameters, filter.IssueId) - filterParameters = buildQueryParameters(filterParameters, filter.ComponentInstanceId) - filterParameters = buildQueryParameters(filterParameters, filter.EvidenceId) - filterParameters = buildQueryParameters(filterParameters, filter.AffectedServiceName) - filterParameters = buildQueryParameters(filterParameters, filter.SeverityValue) - filterParameters = buildQueryParameters(filterParameters, filter.Status) - filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupName) - filterParameters = append(filterParameters, cursor.Value) - filterParameters = append(filterParameters, cursor.Limit) return performListScan( stmt, @@ -193,7 +235,6 @@ func (s *SqlDatabase) GetIssueMatches(filter *entity.IssueMatchFilter) ([]entity } func (s *SqlDatabase) CountIssueMatches(filter *entity.IssueMatchFilter) (int64, error) { - filter = s.ensureIssueMatchFilter(filter) l := logrus.WithFields(logrus.Fields{ "filter": filter, "event": "database.CountIssueMatches", @@ -205,39 +246,11 @@ func (s *SqlDatabase) CountIssueMatches(filter *entity.IssueMatchFilter) (int64, %s ` - filterStr := s.getIssueMatchFilterString(filter) - joins := s.getIssueMatchJoins(filter) - if filterStr != "" { - filterStr = fmt.Sprintf("WHERE %s", filterStr) - } - - query := fmt.Sprintf(baseQuery, joins, filterStr) + stmt, filterParameters, err := s.buildIssueMatchStatement(baseQuery, filter, false, l) - var stmt *sqlx.Stmt - var err error - stmt, err = s.db.Preparex(query) if err != nil { - msg := ERROR_MSG_PREPARED_STMT - l.WithFields( - logrus.Fields{ - "error": err, - "query": query, - "stmt": stmt, - }).Error(msg) - return -1, fmt.Errorf("%s", msg) + return -1, err } - defer stmt.Close() - - //adding parameters - var filterParameters []interface{} - filterParameters = buildQueryParameters(filterParameters, filter.Id) - filterParameters = buildQueryParameters(filterParameters, filter.IssueId) - filterParameters = buildQueryParameters(filterParameters, filter.ComponentInstanceId) - filterParameters = buildQueryParameters(filterParameters, filter.EvidenceId) - filterParameters = buildQueryParameters(filterParameters, filter.AffectedServiceName) - filterParameters = buildQueryParameters(filterParameters, filter.SeverityValue) - filterParameters = buildQueryParameters(filterParameters, filter.Status) - filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupName) return performCountScan(stmt, filterParameters, l) } diff --git a/internal/entity/issue_match.go b/internal/entity/issue_match.go index 46140932..d79c8a83 100644 --- a/internal/entity/issue_match.go +++ b/internal/entity/issue_match.go @@ -66,6 +66,10 @@ type IssueMatchFilter struct { EvidenceId []*int64 `json:"evidence_id"` ComponentInstanceId []*int64 `json:"component_instance_id"` SupportGroupName []*string `json:"support_group_name"` + Search []*string `json:"search"` + ComponentName []*string `json:"component_name"` + PrimaryName []*string `json:"primary_name"` + IssueType []*string `json:"issue_type"` } type IssueMatchResult struct { diff --git a/internal/mocks/mock_Database.go b/internal/mocks/mock_Database.go index 6a9eac07..161bd1ff 100644 --- a/internal/mocks/mock_Database.go +++ b/internal/mocks/mock_Database.go @@ -3453,6 +3453,64 @@ func (_c *MockDatabase_GetComponentInstances_Call) RunAndReturn(run func(*entity return _c } +// GetComponentNames provides a mock function with given fields: filter +func (_m *MockDatabase) GetComponentNames(filter *entity.ComponentFilter) ([]string, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetComponentNames") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) ([]string, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) []string); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(*entity.ComponentFilter) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDatabase_GetComponentNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentNames' +type MockDatabase_GetComponentNames_Call struct { + *mock.Call +} + +// GetComponentNames is a helper method to define mock.On call +// - filter *entity.ComponentFilter +func (_e *MockDatabase_Expecter) GetComponentNames(filter interface{}) *MockDatabase_GetComponentNames_Call { + return &MockDatabase_GetComponentNames_Call{Call: _e.mock.On("GetComponentNames", filter)} +} + +func (_c *MockDatabase_GetComponentNames_Call) Run(run func(filter *entity.ComponentFilter)) *MockDatabase_GetComponentNames_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*entity.ComponentFilter)) + }) + return _c +} + +func (_c *MockDatabase_GetComponentNames_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetComponentNames_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDatabase_GetComponentNames_Call) RunAndReturn(run func(*entity.ComponentFilter) ([]string, error)) *MockDatabase_GetComponentNames_Call { + _c.Call.Return(run) + return _c +} + // GetComponentVersions provides a mock function with given fields: _a0 func (_m *MockDatabase) GetComponentVersions(_a0 *entity.ComponentVersionFilter) ([]entity.ComponentVersion, error) { ret := _m.Called(_a0) @@ -3743,6 +3801,64 @@ func (_c *MockDatabase_GetIssueMatches_Call) RunAndReturn(run func(*entity.Issue return _c } +// GetIssueNames provides a mock function with given fields: _a0 +func (_m *MockDatabase) GetIssueNames(_a0 *entity.IssueFilter) ([]string, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for GetIssueNames") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(*entity.IssueFilter) ([]string, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(*entity.IssueFilter) []string); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(*entity.IssueFilter) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockDatabase_GetIssueNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetIssueNames' +type MockDatabase_GetIssueNames_Call struct { + *mock.Call +} + +// GetIssueNames is a helper method to define mock.On call +// - _a0 *entity.IssueFilter +func (_e *MockDatabase_Expecter) GetIssueNames(_a0 interface{}) *MockDatabase_GetIssueNames_Call { + return &MockDatabase_GetIssueNames_Call{Call: _e.mock.On("GetIssueNames", _a0)} +} + +func (_c *MockDatabase_GetIssueNames_Call) Run(run func(_a0 *entity.IssueFilter)) *MockDatabase_GetIssueNames_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*entity.IssueFilter)) + }) + return _c +} + +func (_c *MockDatabase_GetIssueNames_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetIssueNames_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockDatabase_GetIssueNames_Call) RunAndReturn(run func(*entity.IssueFilter) ([]string, error)) *MockDatabase_GetIssueNames_Call { + _c.Call.Return(run) + return _c +} + // GetIssueRepositories provides a mock function with given fields: _a0 func (_m *MockDatabase) GetIssueRepositories(_a0 *entity.IssueRepositoryFilter) ([]entity.IssueRepository, error) { ret := _m.Called(_a0) diff --git a/internal/mocks/mock_Heureka.go b/internal/mocks/mock_Heureka.go index 2728b9a4..f35ebf57 100644 --- a/internal/mocks/mock_Heureka.go +++ b/internal/mocks/mock_Heureka.go @@ -2256,6 +2256,65 @@ func (_c *MockHeureka_ListComponentInstances_Call) RunAndReturn(run func(*entity return _c } +// ListComponentNames provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListComponentNames(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions) ([]string, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for ListComponentNames") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) []string); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(*entity.ComponentFilter, *entity.ListOptions) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHeureka_ListComponentNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComponentNames' +type MockHeureka_ListComponentNames_Call struct { + *mock.Call +} + +// ListComponentNames is a helper method to define mock.On call +// - _a0 *entity.ComponentFilter +// - _a1 *entity.ListOptions +func (_e *MockHeureka_Expecter) ListComponentNames(_a0 interface{}, _a1 interface{}) *MockHeureka_ListComponentNames_Call { + return &MockHeureka_ListComponentNames_Call{Call: _e.mock.On("ListComponentNames", _a0, _a1)} +} + +func (_c *MockHeureka_ListComponentNames_Call) Run(run func(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions)) *MockHeureka_ListComponentNames_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*entity.ComponentFilter), args[1].(*entity.ListOptions)) + }) + return _c +} + +func (_c *MockHeureka_ListComponentNames_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListComponentNames_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHeureka_ListComponentNames_Call) RunAndReturn(run func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListComponentNames_Call { + _c.Call.Return(run) + return _c +} + // ListComponentVersions provides a mock function with given fields: _a0, _a1 func (_m *MockHeureka) ListComponentVersions(_a0 *entity.ComponentVersionFilter, _a1 *entity.ListOptions) (*entity.List[entity.ComponentVersionResult], error) { ret := _m.Called(_a0, _a1) @@ -2610,6 +2669,65 @@ func (_c *MockHeureka_ListIssueMatches_Call) RunAndReturn(run func(*entity.Issue return _c } +// ListIssueNames provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListIssueNames(_a0 *entity.IssueFilter, _a1 *entity.ListOptions) ([]string, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for ListIssueNames") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(*entity.IssueFilter, *entity.ListOptions) ([]string, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(*entity.IssueFilter, *entity.ListOptions) []string); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(*entity.IssueFilter, *entity.ListOptions) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHeureka_ListIssueNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListIssueNames' +type MockHeureka_ListIssueNames_Call struct { + *mock.Call +} + +// ListIssueNames is a helper method to define mock.On call +// - _a0 *entity.IssueFilter +// - _a1 *entity.ListOptions +func (_e *MockHeureka_Expecter) ListIssueNames(_a0 interface{}, _a1 interface{}) *MockHeureka_ListIssueNames_Call { + return &MockHeureka_ListIssueNames_Call{Call: _e.mock.On("ListIssueNames", _a0, _a1)} +} + +func (_c *MockHeureka_ListIssueNames_Call) Run(run func(_a0 *entity.IssueFilter, _a1 *entity.ListOptions)) *MockHeureka_ListIssueNames_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*entity.IssueFilter), args[1].(*entity.ListOptions)) + }) + return _c +} + +func (_c *MockHeureka_ListIssueNames_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListIssueNames_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHeureka_ListIssueNames_Call) RunAndReturn(run func(*entity.IssueFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListIssueNames_Call { + _c.Call.Return(run) + return _c +} + // ListIssueRepositories provides a mock function with given fields: _a0, _a1 func (_m *MockHeureka) ListIssueRepositories(_a0 *entity.IssueRepositoryFilter, _a1 *entity.ListOptions) (*entity.List[entity.IssueRepositoryResult], error) { ret := _m.Called(_a0, _a1) @@ -2729,27 +2847,27 @@ func (_c *MockHeureka_ListIssueVariants_Call) RunAndReturn(run func(*entity.Issu } // ListIssues provides a mock function with given fields: _a0, _a1 -func (_m *MockHeureka) ListIssues(_a0 *entity.IssueFilter, _a1 *entity.ListOptions) (*entity.List[entity.IssueResult], error) { +func (_m *MockHeureka) ListIssues(_a0 *entity.IssueFilter, _a1 *entity.IssueListOptions) (*entity.IssueList, error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { panic("no return value specified for ListIssues") } - var r0 *entity.List[entity.IssueResult] + var r0 *entity.IssueList var r1 error - if rf, ok := ret.Get(0).(func(*entity.IssueFilter, *entity.ListOptions) (*entity.List[entity.IssueResult], error)); ok { + if rf, ok := ret.Get(0).(func(*entity.IssueFilter, *entity.IssueListOptions) (*entity.IssueList, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(*entity.IssueFilter, *entity.ListOptions) *entity.List[entity.IssueResult]); ok { + if rf, ok := ret.Get(0).(func(*entity.IssueFilter, *entity.IssueListOptions) *entity.IssueList); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*entity.List[entity.IssueResult]) + r0 = ret.Get(0).(*entity.IssueList) } } - if rf, ok := ret.Get(1).(func(*entity.IssueFilter, *entity.ListOptions) error); ok { + if rf, ok := ret.Get(1).(func(*entity.IssueFilter, *entity.IssueListOptions) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -2765,24 +2883,24 @@ type MockHeureka_ListIssues_Call struct { // ListIssues is a helper method to define mock.On call // - _a0 *entity.IssueFilter -// - _a1 *entity.ListOptions +// - _a1 *entity.IssueListOptions func (_e *MockHeureka_Expecter) ListIssues(_a0 interface{}, _a1 interface{}) *MockHeureka_ListIssues_Call { return &MockHeureka_ListIssues_Call{Call: _e.mock.On("ListIssues", _a0, _a1)} } -func (_c *MockHeureka_ListIssues_Call) Run(run func(_a0 *entity.IssueFilter, _a1 *entity.ListOptions)) *MockHeureka_ListIssues_Call { +func (_c *MockHeureka_ListIssues_Call) Run(run func(_a0 *entity.IssueFilter, _a1 *entity.IssueListOptions)) *MockHeureka_ListIssues_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.IssueFilter), args[1].(*entity.ListOptions)) + run(args[0].(*entity.IssueFilter), args[1].(*entity.IssueListOptions)) }) return _c } -func (_c *MockHeureka_ListIssues_Call) Return(_a0 *entity.List[entity.IssueResult], _a1 error) *MockHeureka_ListIssues_Call { +func (_c *MockHeureka_ListIssues_Call) Return(_a0 *entity.IssueList, _a1 error) *MockHeureka_ListIssues_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListIssues_Call) RunAndReturn(run func(*entity.IssueFilter, *entity.ListOptions) (*entity.List[entity.IssueResult], error)) *MockHeureka_ListIssues_Call { +func (_c *MockHeureka_ListIssues_Call) RunAndReturn(run func(*entity.IssueFilter, *entity.IssueListOptions) (*entity.IssueList, error)) *MockHeureka_ListIssues_Call { _c.Call.Return(run) return _c } @@ -3023,8 +3141,8 @@ func (_c *MockHeureka_ListSupportGroups_Call) RunAndReturn(run func(*entity.Supp return _c } -// ListUniqueUserID provides a mock function with given fields: _a0, _a1 -func (_m *MockHeureka) ListUniqueUserID(_a0 *entity.UserFilter, _a1 *entity.ListOptions) ([]string, error) { +// ListUniqueUserIDs provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListUniqueUserIDs(_a0 *entity.UserFilter, _a1 *entity.ListOptions) ([]string, error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { @@ -3053,31 +3171,31 @@ func (_m *MockHeureka) ListUniqueUserID(_a0 *entity.UserFilter, _a1 *entity.List return r0, r1 } -// MockHeureka_ListUniqueUserID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListUniqueUserIDs' -type MockHeureka_ListUniqueUserID_Call struct { +// MockHeureka_ListUniqueUserIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListUniqueUserIDs' +type MockHeureka_ListUniqueUserIDs_Call struct { *mock.Call } -// ListUniqueUserID is a helper method to define mock.On call +// ListUniqueUserIDs is a helper method to define mock.On call // - _a0 *entity.UserFilter // - _a1 *entity.ListOptions -func (_e *MockHeureka_Expecter) ListUniqueUserID(_a0 interface{}, _a1 interface{}) *MockHeureka_ListUniqueUserID_Call { - return &MockHeureka_ListUniqueUserID_Call{Call: _e.mock.On("ListUniqueUserIDs", _a0, _a1)} +func (_e *MockHeureka_Expecter) ListUniqueUserIDs(_a0 interface{}, _a1 interface{}) *MockHeureka_ListUniqueUserIDs_Call { + return &MockHeureka_ListUniqueUserIDs_Call{Call: _e.mock.On("ListUniqueUserIDs", _a0, _a1)} } -func (_c *MockHeureka_ListUniqueUserID_Call) Run(run func(_a0 *entity.UserFilter, _a1 *entity.ListOptions)) *MockHeureka_ListUniqueUserID_Call { +func (_c *MockHeureka_ListUniqueUserIDs_Call) Run(run func(_a0 *entity.UserFilter, _a1 *entity.ListOptions)) *MockHeureka_ListUniqueUserIDs_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(*entity.UserFilter), args[1].(*entity.ListOptions)) }) return _c } -func (_c *MockHeureka_ListUniqueUserID_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListUniqueUserID_Call { +func (_c *MockHeureka_ListUniqueUserIDs_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListUniqueUserIDs_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListUniqueUserID_Call) RunAndReturn(run func(*entity.UserFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListUniqueUserID_Call { +func (_c *MockHeureka_ListUniqueUserIDs_Call) RunAndReturn(run func(*entity.UserFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListUniqueUserIDs_Call { _c.Call.Return(run) return _c }