Add aggregation to GraphQL API; Update frontend

This commit is contained in:
Lou Knauer 2022-03-21 13:28:21 +01:00
parent 220758dae1
commit 8ebf00d980
4 changed files with 78 additions and 33 deletions

@ -1 +1 @@
Subproject commit 184a5079bd53a89442664c28c5cebb733557f1f1 Subproject commit 03818be47032194f1f450ab242eed56a94a3c5d1

View File

@ -143,14 +143,15 @@ type ComplexityRoot struct {
} }
MetricConfig struct { MetricConfig struct {
Alert func(childComplexity int) int Aggregation func(childComplexity int) int
Caution func(childComplexity int) int Alert func(childComplexity int) int
Name func(childComplexity int) int Caution func(childComplexity int) int
Normal func(childComplexity int) int Name func(childComplexity int) int
Peak func(childComplexity int) int Normal func(childComplexity int) int
Scope func(childComplexity int) int Peak func(childComplexity int) int
Timestep func(childComplexity int) int Scope func(childComplexity int) int
Unit func(childComplexity int) int Timestep func(childComplexity int) int
Unit func(childComplexity int) int
} }
MetricFootprints struct { MetricFootprints struct {
@ -709,6 +710,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.JobsStatistics.TotalWalltime(childComplexity), true return e.complexity.JobsStatistics.TotalWalltime(childComplexity), true
case "MetricConfig.aggregation":
if e.complexity.MetricConfig.Aggregation == nil {
break
}
return e.complexity.MetricConfig.Aggregation(childComplexity), true
case "MetricConfig.alert": case "MetricConfig.alert":
if e.complexity.MetricConfig.Alert == nil { if e.complexity.MetricConfig.Alert == nil {
break break
@ -1375,14 +1383,15 @@ type Accelerator {
} }
type MetricConfig { type MetricConfig {
name: String! name: String!
unit: String! unit: String!
scope: MetricScope! scope: MetricScope!
timestep: Int! aggregation: String
peak: Float! timestep: Int!
normal: Float! peak: Float!
caution: Float! normal: Float!
alert: Float! caution: Float!
alert: Float!
} }
type Tag { type Tag {
@ -4202,6 +4211,38 @@ func (ec *executionContext) _MetricConfig_scope(ctx context.Context, field graph
return ec.marshalNMetricScope2githubᚗcomᚋClusterCockpitᚋccᚑbackendᚋschemaᚐMetricScope(ctx, field.Selections, res) return ec.marshalNMetricScope2githubᚗcomᚋClusterCockpitᚋccᚑbackendᚋschemaᚐMetricScope(ctx, field.Selections, res)
} }
func (ec *executionContext) _MetricConfig_aggregation(ctx context.Context, field graphql.CollectedField, obj *model.MetricConfig) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "MetricConfig",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Aggregation, 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.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) _MetricConfig_timestep(ctx context.Context, field graphql.CollectedField, obj *model.MetricConfig) (ret graphql.Marshaler) { func (ec *executionContext) _MetricConfig_timestep(ctx context.Context, field graphql.CollectedField, obj *model.MetricConfig) (ret graphql.Marshaler) {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
@ -8570,6 +8611,8 @@ func (ec *executionContext) _MetricConfig(ctx context.Context, sel ast.Selection
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {
invalids++ invalids++
} }
case "aggregation":
out.Values[i] = ec._MetricConfig_aggregation(ctx, field, obj)
case "timestep": case "timestep":
out.Values[i] = ec._MetricConfig_timestep(ctx, field, obj) out.Values[i] = ec._MetricConfig_timestep(ctx, field, obj)
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {

View File

@ -97,14 +97,15 @@ type JobsStatistics struct {
} }
type MetricConfig struct { type MetricConfig struct {
Name string `json:"name"` Name string `json:"name"`
Unit string `json:"unit"` Unit string `json:"unit"`
Scope schema.MetricScope `json:"scope"` Scope schema.MetricScope `json:"scope"`
Timestep int `json:"timestep"` Aggregation *string `json:"aggregation"`
Peak float64 `json:"peak"` Timestep int `json:"timestep"`
Normal float64 `json:"normal"` Peak float64 `json:"peak"`
Caution float64 `json:"caution"` Normal float64 `json:"normal"`
Alert float64 `json:"alert"` Caution float64 `json:"caution"`
Alert float64 `json:"alert"`
} }
type MetricFootprints struct { type MetricFootprints struct {

View File

@ -68,14 +68,15 @@ type Accelerator {
} }
type MetricConfig { type MetricConfig {
name: String! name: String!
unit: String! unit: String!
scope: MetricScope! scope: MetricScope!
timestep: Int! aggregation: String
peak: Float! timestep: Int!
normal: Float! peak: Float!
caution: Float! normal: Float!
alert: Float! caution: Float!
alert: Float!
} }
type Tag { type Tag {