Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkrzyz committed Nov 13, 2024
1 parent 7ae20da commit 74791eb
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/samber/lo v1.47.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
github.com/vektah/gqlparser/v2 v2.5.19
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
)
Expand Down Expand Up @@ -85,7 +86,6 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/vektah/gqlparser/v2 v2.5.19 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion internal/api/graphql/graph/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func NewServiceWithAggregations(service *entity.ServiceResult) Service {
ID: fmt.Sprintf("%d", service.Id),
Ccrn: &service.CCRN,
ServiceMetadata: &serviceMetadata,
Metadata: getModelMetadata(s.BaseService.Metadata),
Metadata: getModelMetadata(service.BaseService.Metadata),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ query ($filter: IssueFilter, $first: Int, $after: String) {
node {
id
lastModified
metadata {
issueMetadata {
serviceCount
activityCount
issueMatchCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ query ($filter: ServiceFilter, $first: Int, $after: String) {
}
}
}
metadata {
serviceMetadata {
issueMatchCount
componentInstanceCount
}
}
cursor
}
}
}
}
12 changes: 8 additions & 4 deletions internal/database/mariadb/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,10 @@ func (ivwr *IssueVariantWithRepository) AsIssueVariantEntry() entity.IssueVarian
Description: GetStringValue(ivwr.Description),
Metadata: entity.Metadata{
CreatedAt: GetTimeValue(ivwr.IssueVariantRow.CreatedAt),
CreatedBy: GetInt64Value(ivwr.CreatedBy),
DeletedAt: GetTimeValue(ivwr.IssueVariantRow.DeletedAt),
UpdatedAt: GetTimeValue(ivwr.IssueVariantRow.UpdatedAt),
UpdatedBy: GetInt64Value(ivwr.UpdatedBy),
},
}
}
Expand All @@ -437,10 +439,12 @@ func (siv *ServiceIssueVariantRow) AsServiceIssueVariantEntry() entity.ServiceIs
Issue: nil,
Severity: entity.NewSeverity(GetStringValue(siv.Vector)),
Description: GetStringValue(siv.Description),
Info: entity.Info{
CreatedAt: GetTimeValue(siv.IssueVariantRow.CreatedAt),
DeletedAt: GetTimeValue(siv.IssueVariantRow.DeletedAt),
UpdatedAt: GetTimeValue(siv.IssueVariantRow.UpdatedAt),
Metadata: entity.Metadata{
CreatedAt: GetTimeValue(siv.IssueVariantRow.CreatedAt),
CreatedBy: GetInt64Value(siv.CreatedBy),
DeletedAt: GetTimeValue(siv.IssueVariantRow.DeletedAt),
UpdatedAt: GetTimeValue(siv.IssueVariantRow.UpdatedAt),
UpdatedBy: GetInt64Value(siv.UpdatedBy),
},
},
ServiceId: GetInt64Value(siv.IssueRepositoryServiceRow.ServiceId),
Expand Down
2 changes: 1 addition & 1 deletion internal/database/mariadb/init/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ create table if not exists Component
constraint id_UNIQUE
unique (component_id),
constraint component_ccrn_UNIQUE
unique (component_ccrn)
unique (component_ccrn),
constraint fk_component_created_by
foreign key (component_created_by) references User (user_id),
constraint fk_component_updated_by
Expand Down
12 changes: 6 additions & 6 deletions internal/e2e/issue_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ var _ = Describe("Getting Issues via API", Label("e2e", "Issues"), func() {
Expect(*respData.Issues.PageInfo.PageNumber).To(Equal(1), "Correct page number")
})
})
Context("and we request metadata", Label("withMetadata.graphql"), func() {
Context("and we request metadata", Label("withIssueMetadata.graphql"), func() {
It("returns correct metadata counts", func() {
// create a queryCollection (safe to share across requests)
client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port))

//@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work?
b, err := os.ReadFile("../api/graphql/graph/queryCollection/issue/withMetadata.graphql")
b, err := os.ReadFile("../api/graphql/graph/queryCollection/issue/withIssueMetadata.graphql")

Expect(err).To(BeNil())
str := string(b)
Expand All @@ -232,10 +232,10 @@ var _ = Describe("Getting Issues via API", Label("e2e", "Issues"), func() {
ciCount += *imEdge.Node.ComponentInstance.Count
serviceIdSet[imEdge.Node.ComponentInstance.Service.ID] = true
}
Expect(issueEdge.Node.Metadata.IssueMatchCount).To(Equal(issueEdge.Node.IssueMatches.TotalCount), "IssueMatchCount is correct")
Expect(issueEdge.Node.Metadata.ComponentInstanceCount).To(Equal(ciCount), "ComponentInstanceCount is correct")
Expect(issueEdge.Node.Metadata.ActivityCount).To(Equal(issueEdge.Node.Activities.TotalCount), "ActivityCount is correct")
Expect(issueEdge.Node.Metadata.ServiceCount).To(Equal(len(serviceIdSet)), "ServiceCount is correct")
Expect(issueEdge.Node.IssueMetadata.IssueMatchCount).To(Equal(issueEdge.Node.IssueMatches.TotalCount), "IssueMatchCount is correct")
Expect(issueEdge.Node.IssueMetadata.ComponentInstanceCount).To(Equal(ciCount), "ComponentInstanceCount is correct")
Expect(issueEdge.Node.IssueMetadata.ActivityCount).To(Equal(issueEdge.Node.Activities.TotalCount), "ActivityCount is correct")
Expect(issueEdge.Node.IssueMetadata.ServiceCount).To(Equal(len(serviceIdSet)), "ServiceCount is correct")
}
})
})
Expand Down
6 changes: 3 additions & 3 deletions internal/e2e/service_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var _ = Describe("Getting Services via API", Label("e2e", "Services"), func() {
client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port))

//@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work?
b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/withMetadata.graphql")
b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/withServiceMetadata.graphql")

Expect(err).To(BeNil())
str := string(b)
Expand All @@ -146,8 +146,8 @@ var _ = Describe("Getting Services via API", Label("e2e", "Services"), func() {
imCount += ciEdge.Node.IssueMatches.TotalCount
ciCount += *ciEdge.Node.Count
}
Expect(serviceEdge.Node.Metadata.IssueMatchCount).To(Equal(imCount))
Expect(serviceEdge.Node.Metadata.ComponentInstanceCount).To(Equal(ciCount))
Expect(serviceEdge.Node.ServiceMetadata.IssueMatchCount).To(Equal(imCount))
Expect(serviceEdge.Node.ServiceMetadata.ComponentInstanceCount).To(Equal(ciCount))
}
})

Expand Down
1 change: 0 additions & 1 deletion internal/entity/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type HeurekaEntity interface {
ComponentAggregations |
ComponentInstance |
ComponentInstanceAggregations |
ComponentInstance |
ComponentVersion |
ComponentVersionAggregations |
Evidence |
Expand Down
2 changes: 0 additions & 2 deletions internal/entity/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package entity

import "time"

type Component struct {
Metadata
Id int64 `json:"id"`
Expand Down
2 changes: 0 additions & 2 deletions internal/entity/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package entity

import "time"

type BaseService struct {
Metadata
Id int64 `json:"id"`
Expand Down
2 changes: 0 additions & 2 deletions internal/entity/support_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package entity

import "time"

type SupportGroup struct {
Metadata
Id int64 `json:"id"`
Expand Down

0 comments on commit 74791eb

Please sign in to comment.