Skip to content

Commit

Permalink
feat(issueMatch): Fix issueMatch creation by adding CreatedBy field t…
Browse files Browse the repository at this point in the history
…o OnComponentVersionAttachmentToIssue event (#403)

* feat(issueMatch): added created_by field to new issue match in OnComponentVersionAttachmentToIssue event

* updating issue_handler_events.go + test

* docs(comp.backend): ADR - Enable filtering for component instance without support group or service

* feat(authN) - Add updated_by to inserts #360 (#410)

Add assignments in app handlers
Add inserts in database querries
Adjust tests

* ci(keppel): seperate user and keppel domain (#414)

* ci: seperated the user domain from the keppel domain

* ci: fixed typo

---------

Co-authored-by: David Rochow <[email protected]>
Co-authored-by: Dustin Demmerle <[email protected]>
Co-authored-by: dustindemmerle <[email protected]>
Co-authored-by: michalkrzyz <[email protected]>
  • Loading branch information
5 people authored Dec 3, 2024
1 parent bb76a0a commit 6737168
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/app/issue/issue_handler_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
package issue

import (
"time"

"github.com/cloudoperators/heureka/internal/app/common"
"github.com/cloudoperators/heureka/internal/app/event"
"github.com/cloudoperators/heureka/internal/app/shared"
"github.com/cloudoperators/heureka/internal/database"
"github.com/cloudoperators/heureka/internal/entity"
"github.com/sirupsen/logrus"
"time"
)

const (
Expand Down Expand Up @@ -168,9 +170,18 @@ func createIssueMatches(
continue
}

user, err := common.GetCurrentUserId(db)
if err != nil {
l.WithField("event-step", "GetCurrentUserId").WithError(err).Error("Error while getting current user ID")
continue
}

// Create new issue match
issue_match := &entity.IssueMatch{
UserId: 1,
Metadata: entity.Metadata{
CreatedBy: user,
},
UserId: user,
Status: entity.IssueMatchStatusValuesNew,
Severity: issueVariantMap[issueId].Severity, //we got two simply take the first one
ComponentInstanceId: componentInstanceId,
Expand Down
1 change: 1 addition & 0 deletions internal/app/issue/issue_handler_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var _ = Describe("OnComponentVersionAttachmentToIssue", Label("app", "ComponentV
ComponentInstanceId: componentInstance.Id,
IssueId: issueEntity.Id,
}
db.On("GetAllUserIds", mock.Anything).Return([]int64{1}, nil)
db.On("CreateIssueMatch", matchIssueMatch(expectedMatch)).Return(expectedMatch, nil)

// Emit event
Expand Down

0 comments on commit 6737168

Please sign in to comment.