fix: change analysis top users to core hours

This commit is contained in:
Christoph Kluge 2023-08-24 12:51:55 +02:00
parent 6a1e35107f
commit 4eceab4dc7
2 changed files with 8 additions and 2 deletions

View File

@ -478,6 +478,12 @@ func (r *JobRepository) CountGroupedJobs(
now := time.Now().Unix() now := time.Now().Unix()
count = fmt.Sprintf(`sum(job.num_nodes * (CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END)) as count`, now) count = fmt.Sprintf(`sum(job.num_nodes * (CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END)) as count`, now)
runner = r.DB runner = r.DB
case model.WeightsCoreCount:
count = "sum(job.num_hwthreads) as count"
case model.WeightsCoreHours:
now := time.Now().Unix()
count = fmt.Sprintf(`sum(job.num_hwthreads * (CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END)) as count`, now)
runner = r.DB
default: default:
log.Debugf("CountGroupedJobs() Weight %v unknown.", *weight) log.Debugf("CountGroupedJobs() Weight %v unknown.", *weight)
} }

View File

@ -67,7 +67,7 @@
histNumNodes { count, value } histNumNodes { count, value }
} }
topUsers: jobsCount(filter: $jobFilters, groupBy: USER, weight: NODE_HOURS, limit: 5) { name, count } topUsers: jobsCount(filter: $jobFilters, groupBy: USER, weight: CORE_HOURS, limit: 5) { name, count }
} }
`, `,
variables: { jobFilters } variables: { jobFilters }
@ -172,7 +172,7 @@
</Col> </Col>
<Col> <Col>
<Table> <Table>
<tr class="mb-2"><th>Legend</th><th>User Name</th><th>Node Hours</th></tr> <tr class="mb-2"><th>Legend</th><th>User Name</th><th>Core Hours</th></tr>
{#each $statsQuery.data.topUsers.sort((a, b) => b.count - a.count) as { name, count }, i} {#each $statsQuery.data.topUsers.sort((a, b) => b.count - a.count) as { name, count }, i}
<tr> <tr>
<td><Icon name="circle-fill" style="color: {colors[i]};"/></td> <td><Icon name="circle-fill" style="color: {colors[i]};"/></td>