mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-27 05:49:04 +01:00
Show number of short jobs per cluster on start page
Fixes ClusterCockpit/cc-frontend#21
This commit is contained in:
parent
9c6d37118b
commit
8e8b205da8
@ -23,7 +23,7 @@ var groupBy2column = map[model.Aggregate]string{
|
|||||||
model.AggregateCluster: "job.cluster",
|
model.AggregateCluster: "job.cluster",
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShortJobDuration int = 180
|
const ShortJobDuration int = 5 * 60
|
||||||
|
|
||||||
// Helper function for the jobsStatistics GraphQL query placed here so that schema.resolvers.go is not too full.
|
// Helper function for the jobsStatistics GraphQL query placed here so that schema.resolvers.go is not too full.
|
||||||
func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
|
func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
|
||||||
|
12
server.go
12
server.go
@ -129,6 +129,7 @@ func setupHomeRoute(i InfoType, r *http.Request) InfoType {
|
|||||||
Name string
|
Name string
|
||||||
RunningJobs int
|
RunningJobs int
|
||||||
TotalJobs int
|
TotalJobs int
|
||||||
|
RecentShortJobs int
|
||||||
}
|
}
|
||||||
|
|
||||||
runningJobs, err := jobRepo.CountGroupedJobs(r.Context(), model.AggregateCluster, []*model.JobFilter{{
|
runningJobs, err := jobRepo.CountGroupedJobs(r.Context(), model.AggregateCluster, []*model.JobFilter{{
|
||||||
@ -144,12 +145,23 @@ func setupHomeRoute(i InfoType, r *http.Request) InfoType {
|
|||||||
totalJobs = map[string]int{}
|
totalJobs = map[string]int{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from := time.Now().Add(-24 * time.Hour)
|
||||||
|
recentShortJobs, err := jobRepo.CountGroupedJobs(r.Context(), model.AggregateCluster, []*model.JobFilter{{
|
||||||
|
StartTime: &model.TimeRange{From: &from, To: nil},
|
||||||
|
Duration: &model.IntRange{From: 0, To: graph.ShortJobDuration},
|
||||||
|
}}, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to count jobs: %s", err.Error())
|
||||||
|
recentShortJobs = map[string]int{}
|
||||||
|
}
|
||||||
|
|
||||||
clusters := make([]cluster, 0)
|
clusters := make([]cluster, 0)
|
||||||
for _, c := range config.Clusters {
|
for _, c := range config.Clusters {
|
||||||
clusters = append(clusters, cluster{
|
clusters = append(clusters, cluster{
|
||||||
Name: c.Name,
|
Name: c.Name,
|
||||||
RunningJobs: runningJobs[c.Name],
|
RunningJobs: runningJobs[c.Name],
|
||||||
TotalJobs: totalJobs[c.Name],
|
TotalJobs: totalJobs[c.Name],
|
||||||
|
RecentShortJobs: recentShortJobs[c.Name],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Running Jobs</th>
|
<th>Running Jobs</th>
|
||||||
<th>Total Jobs</th>
|
<th>Total Jobs</th>
|
||||||
|
<th>Short Jobs in past 24h</th>
|
||||||
<th>Jobs</th>
|
<th>Jobs</th>
|
||||||
{{if .User.IsAdmin}}
|
{{if .User.IsAdmin}}
|
||||||
<th>System View</th>
|
<th>System View</th>
|
||||||
@ -22,6 +23,7 @@
|
|||||||
<td>{{.Name}}</td>
|
<td>{{.Name}}</td>
|
||||||
<td>{{.RunningJobs}}</td>
|
<td>{{.RunningJobs}}</td>
|
||||||
<td>{{.TotalJobs}}</td>
|
<td>{{.TotalJobs}}</td>
|
||||||
|
<td>{{.RecentShortJobs}}</td>
|
||||||
<td><a href="/monitoring/jobs/?cluster={{.Name}}">Jobs</a></td>
|
<td><a href="/monitoring/jobs/?cluster={{.Name}}">Jobs</a></td>
|
||||||
<td><a href="/monitoring/systems/{{.Name}}">System View</a></td>
|
<td><a href="/monitoring/systems/{{.Name}}">System View</a></td>
|
||||||
<td><a href="/monitoring/analysis/{{.Name}}">Analysis View</a></td>
|
<td><a href="/monitoring/analysis/{{.Name}}">Analysis View</a></td>
|
||||||
@ -33,6 +35,7 @@
|
|||||||
<td>{{.Name}}</td>
|
<td>{{.Name}}</td>
|
||||||
<td>{{.RunningJobs}}</td>
|
<td>{{.RunningJobs}}</td>
|
||||||
<td>{{.TotalJobs}}</td>
|
<td>{{.TotalJobs}}</td>
|
||||||
|
<td>{{.RecentShortJobs}}</td>
|
||||||
<td><a href="/monitoring/jobs/?cluster={{.Name}}">Jobs</a></td>
|
<td><a href="/monitoring/jobs/?cluster={{.Name}}">Jobs</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
Reference in New Issue
Block a user