Skip to content

Commit

Permalink
changed issueMetadata and serviceMetadata to objectMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkrzyz committed Nov 14, 2024
1 parent 22d26ea commit 7b188a6
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion internal/api/graphql/graph/baseResolver/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ func GetListOptions(requestedFields []string) *entity.ListOptions {
return &entity.ListOptions{
ShowTotalCount: lo.Contains(requestedFields, "totalCount"),
ShowPageInfo: lo.Contains(requestedFields, "pageInfo"),
IncludeAggregations: lo.Contains(requestedFields, "edges.node.issueMetadata"),
IncludeAggregations: lo.Contains(requestedFields, "edges.node.objectMetadata"),
}
}
30 changes: 15 additions & 15 deletions internal/api/graphql/graph/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ func NewIssueWithAggregations(issue *entity.IssueResult) Issue {
lastModified := issue.Issue.UpdatedAt.String()
issueType := IssueTypes(issue.Type.String())

var issueMetadata IssueMetadata
var objectMetadata IssueMetadata

if issue.IssueAggregations != nil {
issueMetadata = IssueMetadata{
objectMetadata = IssueMetadata{
ServiceCount: int(issue.IssueAggregations.AffectedServices),
ActivityCount: int(issue.IssueAggregations.Activities),
IssueMatchCount: int(issue.IssueAggregations.IssueMatches),
Expand All @@ -195,13 +195,13 @@ func NewIssueWithAggregations(issue *entity.IssueResult) Issue {
}

return Issue{
ID: fmt.Sprintf("%d", issue.Issue.Id),
PrimaryName: &issue.Issue.PrimaryName,
Type: &issueType,
Description: &issue.Issue.Description,
LastModified: &lastModified,
IssueMetadata: &issueMetadata,
Metadata: getModelMetadata(issue.Issue.Metadata),
ID: fmt.Sprintf("%d", issue.Issue.Id),
PrimaryName: &issue.Issue.PrimaryName,
Type: &issueType,
Description: &issue.Issue.Description,
LastModified: &lastModified,
ObjectMetadata: &objectMetadata,
Metadata: getModelMetadata(issue.Issue.Metadata),
}
}

Expand Down Expand Up @@ -370,20 +370,20 @@ func NewService(s *entity.Service) Service {
}

func NewServiceWithAggregations(service *entity.ServiceResult) Service {
var serviceMetadata ServiceMetadata
var objectMetadata ServiceMetadata

if service.ServiceAggregations != nil {
serviceMetadata = ServiceMetadata{
objectMetadata = ServiceMetadata{
IssueMatchCount: int(service.ServiceAggregations.IssueMatches),
ComponentInstanceCount: int(service.ServiceAggregations.ComponentInstances),
}
}

return Service{
ID: fmt.Sprintf("%d", service.Id),
Ccrn: &service.CCRN,
ServiceMetadata: &serviceMetadata,
Metadata: getModelMetadata(service.BaseService.Metadata),
ID: fmt.Sprintf("%d", service.Id),
Ccrn: &service.CCRN,
ObjectMetadata: &objectMetadata,
Metadata: getModelMetadata(service.BaseService.Metadata),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ query ($filter: IssueFilter, $first: Int, $after: String) {
nextPageAfter
}
}
issueMetadata {
objectMetadata {
serviceCount
activityCount
issueMatchCount
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
issueMetadata {
objectMetadata {
serviceCount
activityCount
issueMatchCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ query ($filter: ServiceFilter, $first: Int, $after: String) {
}
}
}
serviceMetadata {
objectMetadata {
issueMatchCount
componentInstanceCount
}
Expand Down
2 changes: 1 addition & 1 deletion internal/api/graphql/graph/schema/issue.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Issue implements Node {
activities(filter: ActivityFilter, first: Int, after: String): ActivityConnection
issueMatches(filter: IssueMatchFilter, first: Int, after: String): IssueMatchConnection
componentVersions(filter: ComponentVersionFilter, first: Int, after: String): ComponentVersionConnection
issueMetadata: IssueMetadata
objectMetadata: IssueMetadata
metadata: Metadata
}

Expand Down
2 changes: 1 addition & 1 deletion internal/api/graphql/graph/schema/service.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Service implements Node {
activities(filter: ActivityFilter, first: Int, after: String): ActivityConnection
issueRepositories(filter: IssueRepositoryFilter, first: Int, after: String): IssueRepositoryConnection
componentInstances(filter: ComponentInstanceFilter, first: Int, after: String): ComponentInstanceConnection
serviceMetadata: ServiceMetadata
objectMetadata: ServiceMetadata
metadata: Metadata

}
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("withIssueMetadata.graphql"), func() {
Context("and we request metadata", Label("withObjectMetadata.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/withIssueMetadata.graphql")
b, err := os.ReadFile("../api/graphql/graph/queryCollection/issue/withObjectMetadata.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.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")
Expect(issueEdge.Node.ObjectMetadata.IssueMatchCount).To(Equal(issueEdge.Node.IssueMatches.TotalCount), "IssueMatchCount is correct")
Expect(issueEdge.Node.ObjectMetadata.ComponentInstanceCount).To(Equal(ciCount), "ComponentInstanceCount is correct")
Expect(issueEdge.Node.ObjectMetadata.ActivityCount).To(Equal(issueEdge.Node.Activities.TotalCount), "ActivityCount is correct")
Expect(issueEdge.Node.ObjectMetadata.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/withServiceMetadata.graphql")
b, err := os.ReadFile("../api/graphql/graph/queryCollection/service/withObjectMetadata.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.ServiceMetadata.IssueMatchCount).To(Equal(imCount))
Expect(serviceEdge.Node.ServiceMetadata.ComponentInstanceCount).To(Equal(ciCount))
Expect(serviceEdge.Node.ObjectMetadata.IssueMatchCount).To(Equal(imCount))
Expect(serviceEdge.Node.ObjectMetadata.ComponentInstanceCount).To(Equal(ciCount))
}
})

Expand Down

0 comments on commit 7b188a6

Please sign in to comment.