mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 13:29:05 +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",
|
||||
}
|
||||
|
||||
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.
|
||||
func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
|
||||
|
24
server.go
24
server.go
@ -126,9 +126,10 @@ var programConfig ProgramConfig = ProgramConfig{
|
||||
|
||||
func setupHomeRoute(i InfoType, r *http.Request) InfoType {
|
||||
type cluster struct {
|
||||
Name string
|
||||
RunningJobs int
|
||||
TotalJobs int
|
||||
Name string
|
||||
RunningJobs int
|
||||
TotalJobs int
|
||||
RecentShortJobs int
|
||||
}
|
||||
|
||||
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{}
|
||||
}
|
||||
|
||||
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)
|
||||
for _, c := range config.Clusters {
|
||||
clusters = append(clusters, cluster{
|
||||
Name: c.Name,
|
||||
RunningJobs: runningJobs[c.Name],
|
||||
TotalJobs: totalJobs[c.Name],
|
||||
Name: c.Name,
|
||||
RunningJobs: runningJobs[c.Name],
|
||||
TotalJobs: totalJobs[c.Name],
|
||||
RecentShortJobs: recentShortJobs[c.Name],
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
<th>Name</th>
|
||||
<th>Running Jobs</th>
|
||||
<th>Total Jobs</th>
|
||||
<th>Short Jobs in past 24h</th>
|
||||
<th>Jobs</th>
|
||||
{{if .User.IsAdmin}}
|
||||
<th>System View</th>
|
||||
@ -22,6 +23,7 @@
|
||||
<td>{{.Name}}</td>
|
||||
<td>{{.RunningJobs}}</td>
|
||||
<td>{{.TotalJobs}}</td>
|
||||
<td>{{.RecentShortJobs}}</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/analysis/{{.Name}}">Analysis View</a></td>
|
||||
@ -33,6 +35,7 @@
|
||||
<td>{{.Name}}</td>
|
||||
<td>{{.RunningJobs}}</td>
|
||||
<td>{{.TotalJobs}}</td>
|
||||
<td>{{.RecentShortJobs}}</td>
|
||||
<td><a href="/monitoring/jobs/?cluster={{.Name}}">Jobs</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue
Block a user