add job duration, add starttime and duration to legend

This commit is contained in:
Christoph Kluge
2025-05-06 09:58:28 +02:00
parent fd52fdd35b
commit 33ecfe88ef
6 changed files with 137 additions and 36 deletions

View File

@@ -171,6 +171,7 @@ type ComplexityRoot struct {
}
JobStats struct {
Duration func(childComplexity int) int
JobID func(childComplexity int) int
StartTime func(childComplexity int) int
Stats func(childComplexity int) int
@@ -941,6 +942,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.JobResultList.Offset(childComplexity), true
case "JobStats.duration":
if e.complexity.JobStats.Duration == nil {
break
}
return e.complexity.JobStats.Duration(childComplexity), true
case "JobStats.jobId":
if e.complexity.JobStats.JobID == nil {
break
@@ -2290,6 +2298,7 @@ type ScopedStats {
type JobStats {
jobId: Int!
startTime: Int!
duration: Int!
stats: [NamedStats!]!
}
@@ -7453,6 +7462,50 @@ func (ec *executionContext) fieldContext_JobStats_startTime(_ context.Context, f
return fc, nil
}
func (ec *executionContext) _JobStats_duration(ctx context.Context, field graphql.CollectedField, obj *model.JobStats) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_JobStats_duration(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.Duration, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(int)
fc.Result = res
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_JobStats_duration(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "JobStats",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _JobStats_stats(ctx context.Context, field graphql.CollectedField, obj *model.JobStats) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_JobStats_stats(ctx, field)
if err != nil {
@@ -11252,6 +11305,8 @@ func (ec *executionContext) fieldContext_Query_jobsMetricStats(ctx context.Conte
return ec.fieldContext_JobStats_jobId(ctx, field)
case "startTime":
return ec.fieldContext_JobStats_startTime(ctx, field)
case "duration":
return ec.fieldContext_JobStats_duration(ctx, field)
case "stats":
return ec.fieldContext_JobStats_stats(ctx, field)
}
@@ -17587,6 +17642,11 @@ func (ec *executionContext) _JobStats(ctx context.Context, sel ast.SelectionSet,
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "duration":
out.Values[i] = ec._JobStats_duration(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "stats":
out.Values[i] = ec._JobStats_stats(ctx, field, obj)
if out.Values[i] == graphql.Null {

View File

@@ -99,6 +99,7 @@ type JobResultList struct {
type JobStats struct {
JobID int `json:"jobId"`
StartTime int `json:"startTime"`
Duration int `json:"duration"`
Stats []*NamedStats `json:"stats"`
}

View File

@@ -618,6 +618,7 @@ func (r *queryResolver) JobsMetricStats(ctx context.Context, filter []*model.Job
res = append(res, &model.JobStats{
JobID: int(job.JobID),
StartTime: int(job.StartTime.Unix()),
Duration: int(job.Duration),
Stats: sres,
})
}