mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +01:00
Rename histWalltime to histDuration; Fix for running jobs
This commit is contained in:
parent
27b3d78f6e
commit
b47d175ab2
2
frontend
2
frontend
@ -1 +1 @@
|
|||||||
Subproject commit 5d90ff9a4a03242f3a4686c7803dc4b0cee66488
|
Subproject commit 3f3d1fac6b2ea88964ba357ad35688e204d82037
|
@ -133,8 +133,8 @@ type ComplexityRoot struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JobsStatistics struct {
|
JobsStatistics struct {
|
||||||
|
HistDuration func(childComplexity int) int
|
||||||
HistNumNodes func(childComplexity int) int
|
HistNumNodes func(childComplexity int) int
|
||||||
HistWalltime func(childComplexity int) int
|
|
||||||
ID func(childComplexity int) int
|
ID func(childComplexity int) int
|
||||||
ShortJobs func(childComplexity int) int
|
ShortJobs func(childComplexity int) int
|
||||||
TotalCoreHours func(childComplexity int) int
|
TotalCoreHours func(childComplexity int) int
|
||||||
@ -665,6 +665,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.JobResultList.Offset(childComplexity), true
|
return e.complexity.JobResultList.Offset(childComplexity), true
|
||||||
|
|
||||||
|
case "JobsStatistics.histDuration":
|
||||||
|
if e.complexity.JobsStatistics.HistDuration == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.JobsStatistics.HistDuration(childComplexity), true
|
||||||
|
|
||||||
case "JobsStatistics.histNumNodes":
|
case "JobsStatistics.histNumNodes":
|
||||||
if e.complexity.JobsStatistics.HistNumNodes == nil {
|
if e.complexity.JobsStatistics.HistNumNodes == nil {
|
||||||
break
|
break
|
||||||
@ -672,13 +679,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
|
|
||||||
return e.complexity.JobsStatistics.HistNumNodes(childComplexity), true
|
return e.complexity.JobsStatistics.HistNumNodes(childComplexity), true
|
||||||
|
|
||||||
case "JobsStatistics.histWalltime":
|
|
||||||
if e.complexity.JobsStatistics.HistWalltime == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.JobsStatistics.HistWalltime(childComplexity), true
|
|
||||||
|
|
||||||
case "JobsStatistics.id":
|
case "JobsStatistics.id":
|
||||||
if e.complexity.JobsStatistics.ID == nil {
|
if e.complexity.JobsStatistics.ID == nil {
|
||||||
break
|
break
|
||||||
@ -1601,7 +1601,7 @@ type JobsStatistics {
|
|||||||
shortJobs: Int! # Number of jobs with a duration of less than 2 minutes
|
shortJobs: Int! # Number of jobs with a duration of less than 2 minutes
|
||||||
totalWalltime: Int! # Sum of the duration of all matched jobs in hours
|
totalWalltime: Int! # Sum of the duration of all matched jobs in hours
|
||||||
totalCoreHours: Int! # Sum of the core hours of all matched jobs
|
totalCoreHours: Int! # Sum of the core hours of all matched jobs
|
||||||
histWalltime: [HistoPoint!]! # value: hour, count: number of jobs with a rounded duration of value
|
histDuration: [HistoPoint!]! # value: hour, count: number of jobs with a rounded duration of value
|
||||||
histNumNodes: [HistoPoint!]! # value: number of nodes, count: number of jobs with that number of nodes
|
histNumNodes: [HistoPoint!]! # value: number of nodes, count: number of jobs with that number of nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4085,7 +4085,7 @@ func (ec *executionContext) _JobsStatistics_totalCoreHours(ctx context.Context,
|
|||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNInt2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _JobsStatistics_histWalltime(ctx context.Context, field graphql.CollectedField, obj *model.JobsStatistics) (ret graphql.Marshaler) {
|
func (ec *executionContext) _JobsStatistics_histDuration(ctx context.Context, field graphql.CollectedField, obj *model.JobsStatistics) (ret graphql.Marshaler) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
@ -4103,7 +4103,7 @@ func (ec *executionContext) _JobsStatistics_histWalltime(ctx context.Context, fi
|
|||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return obj.HistWalltime, nil
|
return obj.HistDuration, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
@ -8725,8 +8725,8 @@ func (ec *executionContext) _JobsStatistics(ctx context.Context, sel ast.Selecti
|
|||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
invalids++
|
invalids++
|
||||||
}
|
}
|
||||||
case "histWalltime":
|
case "histDuration":
|
||||||
out.Values[i] = ec._JobsStatistics_histWalltime(ctx, field, obj)
|
out.Values[i] = ec._JobsStatistics_histDuration(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
invalids++
|
invalids++
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ type JobsStatistics struct {
|
|||||||
ShortJobs int `json:"shortJobs"`
|
ShortJobs int `json:"shortJobs"`
|
||||||
TotalWalltime int `json:"totalWalltime"`
|
TotalWalltime int `json:"totalWalltime"`
|
||||||
TotalCoreHours int `json:"totalCoreHours"`
|
TotalCoreHours int `json:"totalCoreHours"`
|
||||||
HistWalltime []*HistoPoint `json:"histWalltime"`
|
HistDuration []*HistoPoint `json:"histDuration"`
|
||||||
HistNumNodes []*HistoPoint `json:"histNumNodes"`
|
HistNumNodes []*HistoPoint `json:"histNumNodes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ type JobsStatistics {
|
|||||||
shortJobs: Int! # Number of jobs with a duration of less than 2 minutes
|
shortJobs: Int! # Number of jobs with a duration of less than 2 minutes
|
||||||
totalWalltime: Int! # Sum of the duration of all matched jobs in hours
|
totalWalltime: Int! # Sum of the duration of all matched jobs in hours
|
||||||
totalCoreHours: Int! # Sum of the core hours of all matched jobs
|
totalCoreHours: Int! # Sum of the core hours of all matched jobs
|
||||||
histWalltime: [HistoPoint!]! # value: hour, count: number of jobs with a rounded duration of value
|
histDuration: [HistoPoint!]! # value: hour, count: number of jobs with a rounded duration of value
|
||||||
histNumNodes: [HistoPoint!]! # value: number of nodes, count: number of jobs with that number of nodes
|
histNumNodes: [HistoPoint!]! # value: number of nodes, count: number of jobs with that number of nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/99designs/gqlgen/graphql"
|
"github.com/99designs/gqlgen/graphql"
|
||||||
"github.com/ClusterCockpit/cc-backend/config"
|
"github.com/ClusterCockpit/cc-backend/config"
|
||||||
@ -130,7 +131,7 @@ func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobF
|
|||||||
histogramsNeeded := false
|
histogramsNeeded := false
|
||||||
fields := graphql.CollectFieldsCtx(ctx, nil)
|
fields := graphql.CollectFieldsCtx(ctx, nil)
|
||||||
for _, col := range fields {
|
for _, col := range fields {
|
||||||
if col.Name == "histWalltime" || col.Name == "histNumNodes" {
|
if col.Name == "histDuration" || col.Name == "histNumNodes" {
|
||||||
histogramsNeeded = true
|
histogramsNeeded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +147,8 @@ func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobF
|
|||||||
|
|
||||||
if histogramsNeeded {
|
if histogramsNeeded {
|
||||||
var err error
|
var err error
|
||||||
stat.HistWalltime, err = r.jobsStatisticsHistogram(ctx, "CAST(ROUND(job.duration / 3600) as int) as value", filter, id, col)
|
value := fmt.Sprintf(`CAST(ROUND((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) / 3600) as int) as value`, time.Now().Unix())
|
||||||
|
stat.HistDuration, err = r.jobsStatisticsHistogram(ctx, value, filter, id, col)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user