From 2cdfe8c7168f11cf12a2c51bd47db5ff183dde61 Mon Sep 17 00:00:00 2001 From: Michal Krzyz Date: Thu, 26 Sep 2024 13:52:47 +0200 Subject: [PATCH] feat(authN): Add to all DB entries 'Modified_by'... (#81) Add metadata for activity and IssueVariant --- internal/api/graphql/graph/generated.go | 454 ++++++++++-------- internal/api/graphql/graph/model/models.go | 16 +- .../api/graphql/graph/model/models_gen.go | 16 +- .../issue/directRelations.graphql | 12 +- .../issueRepository/directRelations.graphql | 12 +- .../issueVariant/directRelations.graphql | 12 +- .../graphql/graph/schema/activity.graphqls | 4 +- .../graph/schema/issue_variant.graphqls | 8 +- internal/app/activity/activity_handler.go | 2 + .../issue_variant/issue_variant_handler.go | 2 + internal/database/mariadb/activity.go | 9 +- internal/database/mariadb/entity.go | 16 + internal/database/mariadb/init/schema.sql | 4 + internal/database/mariadb/issue_variant.go | 9 +- internal/database/mariadb/user.go | 2 +- 15 files changed, 339 insertions(+), 239 deletions(-) diff --git a/internal/api/graphql/graph/generated.go b/internal/api/graphql/graph/generated.go index 30881953..b0bfd181 100644 --- a/internal/api/graphql/graph/generated.go +++ b/internal/api/graphql/graph/generated.go @@ -67,6 +67,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int IssueMatchChanges func(childComplexity int, filter *model.IssueMatchChangeFilter, first *int, after *string) int Issues func(childComplexity int, filter *model.IssueFilter, first *int, after *string) int + Metadata func(childComplexity int) int Services func(childComplexity int, filter *model.ServiceFilter, first *int, after *string) int Status func(childComplexity int) int } @@ -78,8 +79,9 @@ type ComplexityRoot struct { } ActivityEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int + Cursor func(childComplexity int) int + Metadata func(childComplexity int) int + Node func(childComplexity int) int } CVSS struct { @@ -341,16 +343,15 @@ type ComplexityRoot struct { } IssueVariant struct { - CreatedAt func(childComplexity int) int Description func(childComplexity int) int ID func(childComplexity int) int Issue func(childComplexity int) int IssueID func(childComplexity int) int IssueRepository func(childComplexity int) int IssueRepositoryID func(childComplexity int) int + Metadata func(childComplexity int) int SecondaryName func(childComplexity int) int Severity func(childComplexity int) int - UpdatedAt func(childComplexity int) int } IssueVariantConnection struct { @@ -360,10 +361,9 @@ type ComplexityRoot struct { } IssueVariantEdge struct { - CreatedAt func(childComplexity int) int - Cursor func(childComplexity int) int - Node func(childComplexity int) int - UpdatedAt func(childComplexity int) int + Cursor func(childComplexity int) int + Metadata func(childComplexity int) int + Node func(childComplexity int) int } Metadata struct { @@ -761,6 +761,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Activity.Issues(childComplexity, args["filter"].(*model.IssueFilter), args["first"].(*int), args["after"].(*string)), true + case "Activity.metadata": + if e.complexity.Activity.Metadata == nil { + break + } + + return e.complexity.Activity.Metadata(childComplexity), true + case "Activity.services": if e.complexity.Activity.Services == nil { break @@ -808,6 +815,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ActivityEdge.Cursor(childComplexity), true + case "ActivityEdge.metadata": + if e.complexity.ActivityEdge.Metadata == nil { + break + } + + return e.complexity.ActivityEdge.Metadata(childComplexity), true + case "ActivityEdge.node": if e.complexity.ActivityEdge.Node == nil { break @@ -2039,13 +2053,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueRepositoryEdge.UpdatedAt(childComplexity), true - case "IssueVariant.created_at": - if e.complexity.IssueVariant.CreatedAt == nil { - break - } - - return e.complexity.IssueVariant.CreatedAt(childComplexity), true - case "IssueVariant.description": if e.complexity.IssueVariant.Description == nil { break @@ -2088,6 +2095,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueVariant.IssueRepositoryID(childComplexity), true + case "IssueVariant.metadata": + if e.complexity.IssueVariant.Metadata == nil { + break + } + + return e.complexity.IssueVariant.Metadata(childComplexity), true + case "IssueVariant.secondaryName": if e.complexity.IssueVariant.SecondaryName == nil { break @@ -2102,13 +2116,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueVariant.Severity(childComplexity), true - case "IssueVariant.updated_at": - if e.complexity.IssueVariant.UpdatedAt == nil { - break - } - - return e.complexity.IssueVariant.UpdatedAt(childComplexity), true - case "IssueVariantConnection.edges": if e.complexity.IssueVariantConnection.Edges == nil { break @@ -2130,13 +2137,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueVariantConnection.TotalCount(childComplexity), true - case "IssueVariantEdge.created_at": - if e.complexity.IssueVariantEdge.CreatedAt == nil { - break - } - - return e.complexity.IssueVariantEdge.CreatedAt(childComplexity), true - case "IssueVariantEdge.cursor": if e.complexity.IssueVariantEdge.Cursor == nil { break @@ -2144,19 +2144,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IssueVariantEdge.Cursor(childComplexity), true - case "IssueVariantEdge.node": - if e.complexity.IssueVariantEdge.Node == nil { + case "IssueVariantEdge.metadata": + if e.complexity.IssueVariantEdge.Metadata == nil { break } - return e.complexity.IssueVariantEdge.Node(childComplexity), true + return e.complexity.IssueVariantEdge.Metadata(childComplexity), true - case "IssueVariantEdge.updated_at": - if e.complexity.IssueVariantEdge.UpdatedAt == nil { + case "IssueVariantEdge.node": + if e.complexity.IssueVariantEdge.Node == nil { break } - return e.complexity.IssueVariantEdge.UpdatedAt(childComplexity), true + return e.complexity.IssueVariantEdge.Node(childComplexity), true case "Metadata.created_at": if e.complexity.Metadata.CreatedAt == nil { @@ -10261,6 +10261,59 @@ func (ec *executionContext) fieldContext_Activity_issueMatchChanges(ctx context. return fc, nil } +func (ec *executionContext) _Activity_metadata(ctx context.Context, field graphql.CollectedField, obj *model.Activity) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Activity_metadata(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.Metadata, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Metadata) + fc.Result = res + return ec.marshalOMetadata2ᚖgithubᚗcomᚋcloudoperatorsᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐMetadata(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Activity_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Activity", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "created_at": + return ec.fieldContext_Metadata_created_at(ctx, field) + case "created_by": + return ec.fieldContext_Metadata_created_by(ctx, field) + case "deleted_at": + return ec.fieldContext_Metadata_deleted_at(ctx, field) + case "updated_at": + return ec.fieldContext_Metadata_updated_at(ctx, field) + case "updated_by": + return ec.fieldContext_Metadata_updated_by(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Metadata", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _ActivityConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.ActivityConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_ActivityConnection_totalCount(ctx, field) if err != nil { @@ -10345,6 +10398,8 @@ func (ec *executionContext) fieldContext_ActivityConnection_edges(_ context.Cont return ec.fieldContext_ActivityEdge_node(ctx, field) case "cursor": return ec.fieldContext_ActivityEdge_cursor(ctx, field) + case "metadata": + return ec.fieldContext_ActivityEdge_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ActivityEdge", field.Name) }, @@ -10458,6 +10513,8 @@ func (ec *executionContext) fieldContext_ActivityEdge_node(_ context.Context, fi return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -10506,6 +10563,59 @@ func (ec *executionContext) fieldContext_ActivityEdge_cursor(_ context.Context, return fc, nil } +func (ec *executionContext) _ActivityEdge_metadata(ctx context.Context, field graphql.CollectedField, obj *model.ActivityEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ActivityEdge_metadata(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.Metadata, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Metadata) + fc.Result = res + return ec.marshalOMetadata2ᚖgithubᚗcomᚋcloudoperatorsᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐMetadata(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ActivityEdge_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ActivityEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "created_at": + return ec.fieldContext_Metadata_created_at(ctx, field) + case "created_by": + return ec.fieldContext_Metadata_created_by(ctx, field) + case "deleted_at": + return ec.fieldContext_Metadata_deleted_at(ctx, field) + case "updated_at": + return ec.fieldContext_Metadata_updated_at(ctx, field) + case "updated_by": + return ec.fieldContext_Metadata_updated_by(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Metadata", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _CVSS_vector(ctx context.Context, field graphql.CollectedField, obj *model.Cvss) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CVSS_vector(ctx, field) if err != nil { @@ -13924,6 +14034,8 @@ func (ec *executionContext) fieldContext_Evidence_activity(_ context.Context, fi return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -16303,6 +16415,8 @@ func (ec *executionContext) fieldContext_IssueMatchChange_activity(_ context.Con return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -18594,49 +18708,8 @@ func (ec *executionContext) fieldContext_IssueVariant_issue(_ context.Context, f return fc, nil } -func (ec *executionContext) _IssueVariant_created_at(ctx context.Context, field graphql.CollectedField, obj *model.IssueVariant) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueVariant_created_at(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.CreatedAt, 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.marshalODateTime2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_IssueVariant_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IssueVariant", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type DateTime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _IssueVariant_updated_at(ctx context.Context, field graphql.CollectedField, obj *model.IssueVariant) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueVariant_updated_at(ctx, field) +func (ec *executionContext) _IssueVariant_metadata(ctx context.Context, field graphql.CollectedField, obj *model.IssueVariant) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueVariant_metadata(ctx, field) if err != nil { return graphql.Null } @@ -18649,7 +18722,7 @@ func (ec *executionContext) _IssueVariant_updated_at(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, nil + return obj.Metadata, nil }) if err != nil { ec.Error(ctx, err) @@ -18658,19 +18731,31 @@ func (ec *executionContext) _IssueVariant_updated_at(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.Metadata) fc.Result = res - return ec.marshalODateTime2ᚖstring(ctx, field.Selections, res) + return ec.marshalOMetadata2ᚖgithubᚗcomᚋcloudoperatorsᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐMetadata(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IssueVariant_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IssueVariant_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "IssueVariant", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type DateTime does not have child fields") + switch field.Name { + case "created_at": + return ec.fieldContext_Metadata_created_at(ctx, field) + case "created_by": + return ec.fieldContext_Metadata_created_by(ctx, field) + case "deleted_at": + return ec.fieldContext_Metadata_deleted_at(ctx, field) + case "updated_at": + return ec.fieldContext_Metadata_updated_at(ctx, field) + case "updated_by": + return ec.fieldContext_Metadata_updated_by(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Metadata", field.Name) }, } return fc, nil @@ -18760,10 +18845,8 @@ func (ec *executionContext) fieldContext_IssueVariantConnection_edges(_ context. return ec.fieldContext_IssueVariantEdge_node(ctx, field) case "cursor": return ec.fieldContext_IssueVariantEdge_cursor(ctx, field) - case "created_at": - return ec.fieldContext_IssueVariantEdge_created_at(ctx, field) - case "updated_at": - return ec.fieldContext_IssueVariantEdge_updated_at(ctx, field) + case "metadata": + return ec.fieldContext_IssueVariantEdge_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type IssueVariantEdge", field.Name) }, @@ -18881,10 +18964,8 @@ func (ec *executionContext) fieldContext_IssueVariantEdge_node(_ context.Context return ec.fieldContext_IssueVariant_issueId(ctx, field) case "issue": return ec.fieldContext_IssueVariant_issue(ctx, field) - case "created_at": - return ec.fieldContext_IssueVariant_created_at(ctx, field) - case "updated_at": - return ec.fieldContext_IssueVariant_updated_at(ctx, field) + case "metadata": + return ec.fieldContext_IssueVariant_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type IssueVariant", field.Name) }, @@ -18933,8 +19014,8 @@ func (ec *executionContext) fieldContext_IssueVariantEdge_cursor(_ context.Conte return fc, nil } -func (ec *executionContext) _IssueVariantEdge_created_at(ctx context.Context, field graphql.CollectedField, obj *model.IssueVariantEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueVariantEdge_created_at(ctx, field) +func (ec *executionContext) _IssueVariantEdge_metadata(ctx context.Context, field graphql.CollectedField, obj *model.IssueVariantEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IssueVariantEdge_metadata(ctx, field) if err != nil { return graphql.Null } @@ -18947,48 +19028,7 @@ func (ec *executionContext) _IssueVariantEdge_created_at(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.CreatedAt, 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.marshalODateTime2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_IssueVariantEdge_created_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "IssueVariantEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type DateTime does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _IssueVariantEdge_updated_at(ctx context.Context, field graphql.CollectedField, obj *model.IssueVariantEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IssueVariantEdge_updated_at(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.UpdatedAt, nil + return obj.Metadata, nil }) if err != nil { ec.Error(ctx, err) @@ -18997,19 +19037,31 @@ func (ec *executionContext) _IssueVariantEdge_updated_at(ctx context.Context, fi if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.Metadata) fc.Result = res - return ec.marshalODateTime2ᚖstring(ctx, field.Selections, res) + return ec.marshalOMetadata2ᚖgithubᚗcomᚋcloudoperatorsᚋheurekaᚋinternalᚋapiᚋgraphqlᚋgraphᚋmodelᚐMetadata(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IssueVariantEdge_updated_at(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IssueVariantEdge_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "IssueVariantEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type DateTime does not have child fields") + switch field.Name { + case "created_at": + return ec.fieldContext_Metadata_created_at(ctx, field) + case "created_by": + return ec.fieldContext_Metadata_created_by(ctx, field) + case "deleted_at": + return ec.fieldContext_Metadata_deleted_at(ctx, field) + case "updated_at": + return ec.fieldContext_Metadata_updated_at(ctx, field) + case "updated_by": + return ec.fieldContext_Metadata_updated_by(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Metadata", field.Name) }, } return fc, nil @@ -21545,10 +21597,8 @@ func (ec *executionContext) fieldContext_Mutation_createIssueVariant(ctx context return ec.fieldContext_IssueVariant_issueId(ctx, field) case "issue": return ec.fieldContext_IssueVariant_issue(ctx, field) - case "created_at": - return ec.fieldContext_IssueVariant_created_at(ctx, field) - case "updated_at": - return ec.fieldContext_IssueVariant_updated_at(ctx, field) + case "metadata": + return ec.fieldContext_IssueVariant_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type IssueVariant", field.Name) }, @@ -21622,10 +21672,8 @@ func (ec *executionContext) fieldContext_Mutation_updateIssueVariant(ctx context return ec.fieldContext_IssueVariant_issueId(ctx, field) case "issue": return ec.fieldContext_IssueVariant_issue(ctx, field) - case "created_at": - return ec.fieldContext_IssueVariant_created_at(ctx, field) - case "updated_at": - return ec.fieldContext_IssueVariant_updated_at(ctx, field) + case "metadata": + return ec.fieldContext_IssueVariant_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type IssueVariant", field.Name) }, @@ -22555,6 +22603,8 @@ func (ec *executionContext) fieldContext_Mutation_createActivity(ctx context.Con return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -22624,6 +22674,8 @@ func (ec *executionContext) fieldContext_Mutation_updateActivity(ctx context.Con return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -22748,6 +22800,8 @@ func (ec *executionContext) fieldContext_Mutation_addServiceToActivity(ctx conte return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -22817,6 +22871,8 @@ func (ec *executionContext) fieldContext_Mutation_removeServiceFromActivity(ctx return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -22886,6 +22942,8 @@ func (ec *executionContext) fieldContext_Mutation_addIssueToActivity(ctx context return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -22955,6 +23013,8 @@ func (ec *executionContext) fieldContext_Mutation_removeIssueFromActivity(ctx co return ec.fieldContext_Activity_evidences(ctx, field) case "issueMatchChanges": return ec.fieldContext_Activity_issueMatchChanges(ctx, field) + case "metadata": + return ec.fieldContext_Activity_metadata(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Activity", field.Name) }, @@ -30088,6 +30148,28 @@ func (ec *executionContext) _Activity(ctx context.Context, sel ast.SelectionSet, continue } out.Values[i] = ec._Activity_issueMatchChanges(ctx, field, obj) + case "metadata": + field := field + + 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 ec._Activity_metadata(ctx, field, obj) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Values[i] = ec._Activity_metadata(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -30272,6 +30354,28 @@ func (ec *executionContext) _ActivityEdge(ctx context.Context, sel ast.Selection continue } out.Values[i] = ec._ActivityEdge_cursor(ctx, field, obj) + case "metadata": + field := field + + 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 ec._ActivityEdge_metadata(ctx, field, obj) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Values[i] = ec._ActivityEdge_metadata(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -35260,29 +35364,7 @@ func (ec *executionContext) _IssueVariant(ctx context.Context, sel ast.Selection continue } out.Values[i] = ec._IssueVariant_issue(ctx, field, obj) - case "created_at": - field := field - - 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 ec._IssueVariant_created_at(ctx, field, obj) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - out.Values[i] = ec._IssueVariant_created_at(ctx, field, obj) - case "updated_at": + case "metadata": field := field if field.Deferrable != nil { @@ -35296,14 +35378,14 @@ func (ec *executionContext) _IssueVariant(ctx context.Context, sel ast.Selection deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return ec._IssueVariant_updated_at(ctx, field, obj) + return ec._IssueVariant_metadata(ctx, field, obj) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } - out.Values[i] = ec._IssueVariant_updated_at(ctx, field, obj) + out.Values[i] = ec._IssueVariant_metadata(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -35488,29 +35570,7 @@ func (ec *executionContext) _IssueVariantEdge(ctx context.Context, sel ast.Selec continue } out.Values[i] = ec._IssueVariantEdge_cursor(ctx, field, obj) - case "created_at": - field := field - - 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 ec._IssueVariantEdge_created_at(ctx, field, obj) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - out.Values[i] = ec._IssueVariantEdge_created_at(ctx, field, obj) - case "updated_at": + case "metadata": field := field if field.Deferrable != nil { @@ -35524,14 +35584,14 @@ func (ec *executionContext) _IssueVariantEdge(ctx context.Context, sel ast.Selec deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return ec._IssueVariantEdge_updated_at(ctx, field, obj) + return ec._IssueVariantEdge_metadata(ctx, field, obj) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } - out.Values[i] = ec._IssueVariantEdge_updated_at(ctx, field, obj) + out.Values[i] = ec._IssueVariantEdge_metadata(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/internal/api/graphql/graph/model/models.go b/internal/api/graphql/graph/model/models.go index e66b693c..0f6cd790 100644 --- a/internal/api/graphql/graph/model/models.go +++ b/internal/api/graphql/graph/model/models.go @@ -286,8 +286,6 @@ func NewIssueVariant(issueVariant *entity.IssueVariant) IssueVariant { if issueVariant.IssueRepository != nil { repo = NewIssueRepository(issueVariant.IssueRepository) } - createdAt := issueVariant.CreatedAt.String() - updatedAt := issueVariant.UpdatedAt.String() return IssueVariant{ ID: fmt.Sprintf("%d", issueVariant.Id), SecondaryName: &issueVariant.SecondaryName, @@ -296,20 +294,16 @@ func NewIssueVariant(issueVariant *entity.IssueVariant) IssueVariant { IssueID: util.Ptr(fmt.Sprintf("%d", issueVariant.IssueId)), IssueRepositoryID: util.Ptr(fmt.Sprintf("%d", issueVariant.IssueRepositoryId)), IssueRepository: &repo, - CreatedAt: &createdAt, - UpdatedAt: &updatedAt, + Metadata: getModelMetadata(issueVariant.Metadata), } } func NewIssueVariantEdge(issueVariant *entity.IssueVariant) IssueVariantEdge { iv := NewIssueVariant(issueVariant) - edgeCreationDate := issueVariant.CreatedAt.String() - edgeUpdateDate := issueVariant.UpdatedAt.String() issueVariantEdge := IssueVariantEdge{ Node: &iv, Cursor: &iv.ID, - CreatedAt: &edgeCreationDate, - UpdatedAt: &edgeUpdateDate, + Metadata: getModelMetadata(issueVariant.Metadata), } return issueVariantEdge } @@ -375,9 +369,9 @@ func NewSupportGroupEntity(supportGroup *SupportGroupInput) entity.SupportGroup func NewActivity(activity *entity.Activity) Activity { status := ActivityStatusValues(activity.Status.String()) return Activity{ - ID: fmt.Sprintf("%d", activity.Id), - Status: &status, - //Metadata: activity.getModelMetadata(activitiy), + ID: fmt.Sprintf("%d", activity.Id), + Status: &status, + Metadata: getModelMetadata(activity.Metadata), } } diff --git a/internal/api/graphql/graph/model/models_gen.go b/internal/api/graphql/graph/model/models_gen.go index 2557d136..224b5da0 100644 --- a/internal/api/graphql/graph/model/models_gen.go +++ b/internal/api/graphql/graph/model/models_gen.go @@ -32,6 +32,7 @@ type Activity struct { Issues *IssueConnection `json:"issues,omitempty"` Evidences *EvidenceConnection `json:"evidences,omitempty"` IssueMatchChanges *IssueMatchChangeConnection `json:"issueMatchChanges,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` } func (Activity) IsNode() {} @@ -48,8 +49,9 @@ func (this ActivityConnection) GetTotalCount() int { return this.TotalCount func (this ActivityConnection) GetPageInfo() *PageInfo { return this.PageInfo } type ActivityEdge struct { - Node *Activity `json:"node"` - Cursor *string `json:"cursor,omitempty"` + Node *Activity `json:"node"` + Cursor *string `json:"cursor,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` } func (ActivityEdge) IsEdge() {} @@ -526,8 +528,7 @@ type IssueVariant struct { IssueRepository *IssueRepository `json:"issueRepository,omitempty"` IssueID *string `json:"issueId,omitempty"` Issue *Issue `json:"issue,omitempty"` - CreatedAt *string `json:"created_at,omitempty"` - UpdatedAt *string `json:"updated_at,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` } func (IssueVariant) IsNode() {} @@ -544,10 +545,9 @@ func (this IssueVariantConnection) GetTotalCount() int { return this.TotalCo func (this IssueVariantConnection) GetPageInfo() *PageInfo { return this.PageInfo } type IssueVariantEdge struct { - Node *IssueVariant `json:"node"` - Cursor *string `json:"cursor,omitempty"` - CreatedAt *string `json:"created_at,omitempty"` - UpdatedAt *string `json:"updated_at,omitempty"` + Node *IssueVariant `json:"node"` + Cursor *string `json:"cursor,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` } func (IssueVariantEdge) IsEdge() {} diff --git a/internal/api/graphql/graph/queryCollection/issue/directRelations.graphql b/internal/api/graphql/graph/queryCollection/issue/directRelations.graphql index 31c599d7..328cfd30 100644 --- a/internal/api/graphql/graph/queryCollection/issue/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/issue/directRelations.graphql @@ -37,12 +37,16 @@ query ($filter: IssueFilter, $first: Int, $after: String) { updated_at } issueId + metadata { + created_at + updated_at + } + } + cursor + metadata { created_at updated_at } - cursor - created_at - updated_at } pageInfo { hasNextPage @@ -98,4 +102,4 @@ query ($filter: IssueFilter, $first: Int, $after: String) { } } } -} \ No newline at end of file +} diff --git a/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql b/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql index 259d50d3..f77fa4e0 100644 --- a/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql @@ -23,12 +23,16 @@ query ($filter: IssueRepositoryFilter, $first: Int, $after: String) { description issueRepositoryId issueId + metadata { + created_at + updated_at + } + } + cursor + metadata { created_at updated_at } - cursor - created_at - updated_at } pageInfo { hasNextPage @@ -71,4 +75,4 @@ query ($filter: IssueRepositoryFilter, $first: Int, $after: String) { } } } -} \ No newline at end of file +} diff --git a/internal/api/graphql/graph/queryCollection/issueVariant/directRelations.graphql b/internal/api/graphql/graph/queryCollection/issueVariant/directRelations.graphql index f2402acd..aeb59141 100644 --- a/internal/api/graphql/graph/queryCollection/issueVariant/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/issueVariant/directRelations.graphql @@ -31,12 +31,16 @@ query ($filter: IssueVariantFilter, $first: Int, $after: String) { id lastModified } + metadata { + created_at + updated_at + } + } + cursor + metadata { created_at updated_at } - cursor - created_at - updated_at } pageInfo { hasNextPage @@ -52,4 +56,4 @@ query ($filter: IssueVariantFilter, $first: Int, $after: String) { } } } -} \ No newline at end of file +} diff --git a/internal/api/graphql/graph/schema/activity.graphqls b/internal/api/graphql/graph/schema/activity.graphqls index b7ccc630..2ebe53b2 100644 --- a/internal/api/graphql/graph/schema/activity.graphqls +++ b/internal/api/graphql/graph/schema/activity.graphqls @@ -8,6 +8,7 @@ type Activity implements Node { issues(filter: IssueFilter, first: Int, after: String): IssueConnection evidences(filter: EvidenceFilter, first: Int, after: String): EvidenceConnection issueMatchChanges(filter: IssueMatchChangeFilter, first: Int, after: String): IssueMatchChangeConnection + metadata: Metadata } input ActivityInput { @@ -23,6 +24,7 @@ type ActivityConnection implements Connection { type ActivityEdge implements Edge { node: Activity! cursor: String + metadata: Metadata } input ActivityFilter { @@ -34,4 +36,4 @@ enum ActivityStatusValues { open, closed, in_progress -} \ No newline at end of file +} diff --git a/internal/api/graphql/graph/schema/issue_variant.graphqls b/internal/api/graphql/graph/schema/issue_variant.graphqls index f6ffc280..36d1d9be 100644 --- a/internal/api/graphql/graph/schema/issue_variant.graphqls +++ b/internal/api/graphql/graph/schema/issue_variant.graphqls @@ -10,8 +10,7 @@ type IssueVariant implements Node { issueRepository: IssueRepository issueId: String issue: Issue - created_at: DateTime - updated_at: DateTime + metadata: Metadata } input IssueVariantInput { @@ -31,10 +30,9 @@ type IssueVariantConnection implements Connection { type IssueVariantEdge implements Edge { node: IssueVariant! cursor: String - created_at: DateTime - updated_at: DateTime + metadata: Metadata } input IssueVariantFilter { secondaryName: [String] -} \ No newline at end of file +} diff --git a/internal/app/activity/activity_handler.go b/internal/app/activity/activity_handler.go index b85dd821..bccec92d 100644 --- a/internal/app/activity/activity_handler.go +++ b/internal/app/activity/activity_handler.go @@ -132,6 +132,7 @@ func (a *activityHandler) ListActivities(filter *entity.ActivityFilter, options } func (a *activityHandler) CreateActivity(activity *entity.Activity) (*entity.Activity, error) { + activity.CreatedBy = "Creator" l := logrus.WithFields(logrus.Fields{ "event": ActivityCreateEventName, "object": activity, @@ -152,6 +153,7 @@ func (a *activityHandler) CreateActivity(activity *entity.Activity) (*entity.Act } func (a *activityHandler) UpdateActivity(activity *entity.Activity) (*entity.Activity, error) { + activity.UpdatedBy = "Updater" l := logrus.WithFields(logrus.Fields{ "event": ActivityUpdateEventName, "object": activity, diff --git a/internal/app/issue_variant/issue_variant_handler.go b/internal/app/issue_variant/issue_variant_handler.go index 6ac751e8..3e7f2cd0 100644 --- a/internal/app/issue_variant/issue_variant_handler.go +++ b/internal/app/issue_variant/issue_variant_handler.go @@ -168,6 +168,7 @@ func (iv *issueVariantHandler) ListEffectiveIssueVariants(filter *entity.IssueVa } func (iv *issueVariantHandler) CreateIssueVariant(issueVariant *entity.IssueVariant) (*entity.IssueVariant, error) { + issueVariant.CreatedBy = "Creator" f := &entity.IssueVariantFilter{ SecondaryName: []*string{&issueVariant.SecondaryName}, } @@ -203,6 +204,7 @@ func (iv *issueVariantHandler) CreateIssueVariant(issueVariant *entity.IssueVari } func (iv *issueVariantHandler) UpdateIssueVariant(issueVariant *entity.IssueVariant) (*entity.IssueVariant, error) { + issueVariant.UpdatedBy = "Updater" l := logrus.WithFields(logrus.Fields{ "event": UpdateIssueVariantEventName, "object": issueVariant, diff --git a/internal/database/mariadb/activity.go b/internal/database/mariadb/activity.go index 681f0543..e5bd8aee 100644 --- a/internal/database/mariadb/activity.go +++ b/internal/database/mariadb/activity.go @@ -68,6 +68,9 @@ func (s *SqlDatabase) getActivityUpdateFields(activity *entity.Activity) string if activity.Status != "" { fl = append(fl, "activity_status = :activity_status") } + if activity.UpdatedBy != "" { + fl = append(fl, "activity_updated_by = :activity_updated_by") + } return strings.Join(fl, ", ") } @@ -208,9 +211,11 @@ func (s *SqlDatabase) CreateActivity(activity *entity.Activity) (*entity.Activit query := ` INSERT INTO Activity ( - activity_status + activity_status, + activity_created_by ) VALUES ( - :activity_status + :activity_status, + :activity_created_by ) ` diff --git a/internal/database/mariadb/entity.go b/internal/database/mariadb/entity.go index 2e802693..101e44a6 100644 --- a/internal/database/mariadb/entity.go +++ b/internal/database/mariadb/entity.go @@ -1,6 +1,10 @@ // SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors // SPDX-License-Identifier: Apache-2.0 +//TODO: add Metadata type for mariadb package +//TODO: add Metadata converter mariadb - entity +//TODO: add Metadata converter entity - mariadb + package mariadb import ( @@ -322,8 +326,10 @@ type IssueVariantRow struct { Rating sql.NullString `db:"issuevariant_rating" json:"rating"` Description sql.NullString `db:"issuevariant_description" json:"description"` CreatedAt sql.NullTime `db:"issuevariant_created_at" json:"created_at"` + CreatedBy sql.NullString `db:"issuevariant_created_by" json:"created_by"` DeletedAt sql.NullTime `db:"issuevariant_deleted_at" json:"deleted_at,omitempty"` UpdatedAt sql.NullTime `db:"issuevariant_updated_at" json:"updated_at"` + UpdatedBy sql.NullString `db:"issuevariant_updated_by" json:"updated_by"` } func (ivr *IssueVariantRow) AsIssueVariant(repository *entity.IssueRepository) entity.IssueVariant { @@ -338,8 +344,10 @@ func (ivr *IssueVariantRow) AsIssueVariant(repository *entity.IssueRepository) e Description: GetStringValue(ivr.Description), Metadata: entity.Metadata{ CreatedAt: GetTimeValue(ivr.CreatedAt), + CreatedBy: GetStringValue(ivr.CreatedBy), DeletedAt: GetTimeValue(ivr.DeletedAt), UpdatedAt: GetTimeValue(ivr.UpdatedAt), + UpdatedBy: GetStringValue(ivr.UpdatedBy), }, } } @@ -353,8 +361,10 @@ func (ivr *IssueVariantRow) FromIssueVariant(iv *entity.IssueVariant) { ivr.Rating = sql.NullString{String: iv.Severity.Value, Valid: true} ivr.Description = sql.NullString{String: iv.Description, Valid: true} ivr.CreatedAt = sql.NullTime{Time: iv.CreatedAt, Valid: true} + ivr.CreatedBy = sql.NullString{String: iv.CreatedBy, Valid: true} ivr.DeletedAt = sql.NullTime{Time: iv.DeletedAt, Valid: true} ivr.UpdatedAt = sql.NullTime{Time: iv.UpdatedAt, Valid: true} + ivr.UpdatedBy = sql.NullString{String: iv.UpdatedBy, Valid: true} } type IssueVariantWithRepository struct { @@ -537,8 +547,10 @@ type ActivityRow struct { Id sql.NullInt64 `db:"activity_id" json:"id"` Status sql.NullString `db:"activity_status" json:"status"` CreatedAt sql.NullTime `db:"activity_created_at" json:"created_at"` + CreatedBy sql.NullString `db:"activity_created_by" json:"created_by"` DeletedAt sql.NullTime `db:"activity_deleted_at" json:"deleted_at,omitempty"` UpdatedAt sql.NullTime `db:"activity_updated_at" json:"updated_at"` + UpdatedBy sql.NullString `db:"activity_updated_by" json:"updated_by"` } func (ar *ActivityRow) AsActivity() entity.Activity { @@ -549,8 +561,10 @@ func (ar *ActivityRow) AsActivity() entity.Activity { Evidences: []entity.Evidence{}, Metadata: entity.Metadata{ CreatedAt: GetTimeValue(ar.CreatedAt), + CreatedBy: GetStringValue(ar.CreatedBy), DeletedAt: GetTimeValue(ar.DeletedAt), UpdatedAt: GetTimeValue(ar.UpdatedAt), + UpdatedBy: GetStringValue(ar.UpdatedBy), }, } } @@ -559,8 +573,10 @@ func (ar *ActivityRow) FromActivity(a *entity.Activity) { ar.Id = sql.NullInt64{Int64: a.Id, Valid: true} ar.Status = sql.NullString{String: a.Status.String(), Valid: true} ar.CreatedAt = sql.NullTime{Time: a.CreatedAt, Valid: true} + ar.CreatedBy = sql.NullString{String: a.CreatedBy, Valid: true} ar.DeletedAt = sql.NullTime{Time: a.DeletedAt, Valid: true} ar.UpdatedAt = sql.NullTime{Time: a.UpdatedAt, Valid: true} + ar.UpdatedBy = sql.NullString{String: a.UpdatedBy, Valid: true} } type ComponentInstanceRow struct { diff --git a/internal/database/mariadb/init/schema.sql b/internal/database/mariadb/init/schema.sql index c8a82d9d..298b8f92 100644 --- a/internal/database/mariadb/init/schema.sql +++ b/internal/database/mariadb/init/schema.sql @@ -88,8 +88,10 @@ create table if not exists Activity primary key, activity_status enum('open','closed','in_progress') not null, activity_created_at timestamp default current_timestamp() not null, + activity_created_by varchar(256) null, activity_deleted_at timestamp null, activity_updated_at timestamp default current_timestamp() not null on update current_timestamp(), + activity_updated_by varchar(256) null, constraint id_UNIQUE unique (activity_id) ); @@ -237,8 +239,10 @@ create table if not exists IssueVariant issuevariant_secondary_name varchar(256) not null, issuevariant_description longtext not null, issuevariant_created_at timestamp default current_timestamp() not null, + issuevariant_created_by varchar(256) null, issuevariant_deleted_at timestamp null, issuevariant_updated_at timestamp default current_timestamp() not null on update current_timestamp(), + issuevariant_updated_by varchar(256) null, constraint id_UNIQUE unique (issuevariant_id), constraint name_UNIQUE diff --git a/internal/database/mariadb/issue_variant.go b/internal/database/mariadb/issue_variant.go index 651a28e7..bec8ecec 100644 --- a/internal/database/mariadb/issue_variant.go +++ b/internal/database/mariadb/issue_variant.go @@ -96,6 +96,9 @@ func (s *SqlDatabase) getIssueVariantUpdateFields(issueVariant *entity.IssueVari if issueVariant.IssueRepositoryId != 0 { fl = append(fl, "issuevariant_repository_id = :issuevariant_repository_id") } + if issueVariant.UpdatedBy != "" { + fl = append(fl, "issuevariant_updated_by = :issuevariant_updated_by") + } return strings.Join(fl, ", ") } @@ -242,14 +245,16 @@ func (s *SqlDatabase) CreateIssueVariant(issueVariant *entity.IssueVariant) (*en issuevariant_vector, issuevariant_rating, issuevariant_secondary_name, - issuevariant_description + issuevariant_description, + issuevariant_created_by ) VALUES ( :issuevariant_issue_id, :issuevariant_repository_id, :issuevariant_vector, :issuevariant_rating, :issuevariant_secondary_name, - :issuevariant_description + :issuevariant_description, + :issuevariant_created_by ) ` diff --git a/internal/database/mariadb/user.go b/internal/database/mariadb/user.go index 86fd3127..f5405dcd 100644 --- a/internal/database/mariadb/user.go +++ b/internal/database/mariadb/user.go @@ -62,7 +62,7 @@ func (s *SqlDatabase) getUserUpdateFields(user *entity.User) string { if user.Type != entity.InvalidUserType { fl = append(fl, "user_type = :user_type") } - if user.Metadata.UpdatedBy != "" { + if user.UpdatedBy != "" { fl = append(fl, "user_updated_by = :user_updated_by") }