mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-23 12:51:40 +02:00
Refactor schema
* Remove redundant scope * Change Series Id type to string * Adopt golang structs to schema
This commit is contained in:
@@ -158,7 +158,6 @@ func (ccms *CCMetricStore) LoadData(
|
||||
scopes []schema.MetricScope,
|
||||
ctx context.Context) (schema.JobData, error) {
|
||||
|
||||
topology := archive.GetSubCluster(job.Cluster, job.SubCluster).Topology
|
||||
queries, assignedScope, err := ccms.buildQueries(job, metrics, scopes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -193,7 +192,6 @@ func (ccms *CCMetricStore) LoadData(
|
||||
if !ok {
|
||||
jobMetric = &schema.JobMetric{
|
||||
Unit: mc.Unit,
|
||||
Scope: scope,
|
||||
Timestep: mc.Timestep,
|
||||
Series: make([]schema.Series, 0),
|
||||
}
|
||||
@@ -206,13 +204,10 @@ func (ccms *CCMetricStore) LoadData(
|
||||
continue
|
||||
}
|
||||
|
||||
id := (*int)(nil)
|
||||
id := (*string)(nil)
|
||||
if query.Type != nil {
|
||||
id = new(int)
|
||||
*id, err = strconv.Atoi(query.TypeIds[0])
|
||||
if err != nil || *query.Type == acceleratorString {
|
||||
*id, _ = topology.GetAcceleratorIndex(query.TypeIds[0])
|
||||
}
|
||||
id = new(string)
|
||||
*id = query.TypeIds[0]
|
||||
}
|
||||
|
||||
if res.Avg.IsNaN() || res.Min.IsNaN() || res.Max.IsNaN() {
|
||||
@@ -226,7 +221,7 @@ func (ccms *CCMetricStore) LoadData(
|
||||
jobMetric.Series = append(jobMetric.Series, schema.Series{
|
||||
Hostname: query.Hostname,
|
||||
Id: id,
|
||||
Statistics: &schema.MetricStatistics{
|
||||
Statistics: schema.MetricStatistics{
|
||||
Avg: float64(res.Avg),
|
||||
Min: float64(res.Min),
|
||||
Max: float64(res.Max),
|
||||
@@ -610,13 +605,12 @@ func (ccms *CCMetricStore) LoadNodeData(
|
||||
mc := archive.GetMetricConfig(cluster, metric)
|
||||
hostdata[metric] = append(hostdata[metric], &schema.JobMetric{
|
||||
Unit: mc.Unit,
|
||||
Scope: schema.MetricScopeNode,
|
||||
Timestep: mc.Timestep,
|
||||
Series: []schema.Series{
|
||||
{
|
||||
Hostname: query.Hostname,
|
||||
Data: qdata.Data,
|
||||
Statistics: &schema.MetricStatistics{
|
||||
Statistics: schema.MetricStatistics{
|
||||
Avg: float64(qdata.Avg),
|
||||
Min: float64(qdata.Min),
|
||||
Max: float64(qdata.Max),
|
||||
|
Reference in New Issue
Block a user