Skip to content

Commit

Permalink
feat(authN): Add to all DB entries 'Modified_by'... (#81)
Browse files Browse the repository at this point in the history
Add metadata for user
Add tests
  • Loading branch information
michalkrzyz committed Sep 26, 2024
1 parent cb2f9c1 commit 419e412
Show file tree
Hide file tree
Showing 59 changed files with 12,771 additions and 4,129 deletions.
16,367 changes: 12,400 additions & 3,967 deletions internal/api/graphql/graph/generated.go

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion internal/api/graphql/graph/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ import (
)

// add custom models here
func getModelMetadata(em entity.Metadata) *Metadata {
createdAt := em.CreatedAt.String()
deletedAt := em.DeletedAt.String()
updatedAt := em.UpdatedAt.String()
return &Metadata{
CreatedAt: &createdAt,
CreatedBy: &em.CreatedBy,
DeletedAt: &deletedAt,
UpdatedAt: &updatedAt,
UpdatedBy: &em.UpdatedBy,
}
}

func NewPageInfo(p *entity.PageInfo) *PageInfo {
if p == nil {
Expand Down Expand Up @@ -219,7 +231,7 @@ func NewIssueMatchEntity(im *IssueMatchInput) entity.IssueMatch {
IssueId: issueId,
ComponentInstanceId: ciId,
UserId: userId,
Info: entity.Info{CreatedAt: createdAt},
Metadata: entity.Metadata{CreatedAt: createdAt},
}
}

Expand Down Expand Up @@ -320,6 +332,7 @@ func NewUser(user *entity.User) User {
UniqueUserID: &user.UniqueUserID,
Name: &user.Name,
Type: int(user.Type),
Metadata: getModelMetadata(user.Metadata),
}
}

Expand Down Expand Up @@ -364,6 +377,7 @@ func NewActivity(activity *entity.Activity) Activity {
return Activity{
ID: fmt.Sprintf("%d", activity.Id),
Status: &status,
//Metadata: activity.getModelMetadata(activitiy),
}
}

Expand Down
12 changes: 9 additions & 3 deletions internal/api/graphql/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions internal/api/graphql/graph/queryCollection/user/listUsers.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

query ($filter: UserFilter, $first: Int, $after: String) {
Users (
filter: $filter,
first: $first,
after: $after
) {
totalCount
edges {
node {
id
name
type
metadata {
created_at
created_by
deleted_at
updated_at
updated_by
}
}
cursor
}
}
}
5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/activity.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/component.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/component_instance.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/component_version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/evidence.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_match.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_match_change.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/issue_variant.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/mutation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/service_filter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/support_group.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/api/graphql/graph/resolver/user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion internal/api/graphql/graph/schema/common.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,12 @@ type FilterItem {
displayName: String
filterName: String
values: [String]
}
}

type Metadata {
created_at: DateTime
created_by: String
deleted_at: DateTime
updated_at: DateTime
updated_by: String
}
1 change: 1 addition & 0 deletions internal/api/graphql/graph/schema/user.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type User implements Node {
name: String
supportGroups(filter: SupportGroupFilter, first: Int, after: String): SupportGroupConnection
services(filter: ServiceFilter, first: Int, after: String): ServiceConnection
metadata: Metadata
}

input UserInput {
Expand Down
2 changes: 2 additions & 0 deletions internal/app/user/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (u *userHandler) ListUsers(filter *entity.UserFilter, options *entity.ListO
}

func (u *userHandler) CreateUser(user *entity.User) (*entity.User, error) {
user.CreatedBy = "Creator"
f := &entity.UserFilter{
UniqueUserID: []*string{&user.UniqueUserID},
}
Expand Down Expand Up @@ -136,6 +137,7 @@ func (u *userHandler) CreateUser(user *entity.User) (*entity.User, error) {
}

func (u *userHandler) UpdateUser(user *entity.User) (*entity.User, error) {
user.UpdatedBy = "Updater"
l := logrus.WithFields(logrus.Fields{
"event": UpdateUserEventName,
"object": user,
Expand Down
Loading

0 comments on commit 419e412

Please sign in to comment.