mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 12:59:06 +01:00
fix wrong flag labelling, change to kWh energy calculation
This commit is contained in:
parent
82baf5d384
commit
615281601c
@ -603,12 +603,13 @@ func (r *JobRepository) UpdateEnergy(
|
|||||||
|
|
||||||
for _, fp := range sc.EnergyFootprint {
|
for _, fp := range sc.EnergyFootprint {
|
||||||
if i, err := archive.MetricIndex(sc.MetricConfig, fp); err == nil {
|
if i, err := archive.MetricIndex(sc.MetricConfig, fp); err == nil {
|
||||||
// FIXME: Check for unit conversions
|
// Note: For DB data, calculate and save as kWh
|
||||||
// Energy: Watts * Time // Power: Energy / Time -> Correct labelling here?
|
// Energy: Power (in Watts) * Time (in Seconds)
|
||||||
if sc.MetricConfig[i].Energy == "power" {
|
if sc.MetricConfig[i].Energy == "energy" {
|
||||||
// Unit: ( W * s ) / 3600 = Wh ; Rounded to 2 nearest digits
|
// Unit: ( W * s ) / 3600 / 1000 = kWh ; Rounded to 2 nearest digits
|
||||||
energy = math.Round(((LoadJobStat(jobMeta, fp, "avg")*float64(jobMeta.Duration))/3600)*100) / 100
|
energy = math.Round(((LoadJobStat(jobMeta, fp, "avg")*float64(jobMeta.Duration))/3600/1000)*100) / 100
|
||||||
} else if sc.MetricConfig[i].Energy == "energy" {
|
// Power: Use directly as sum (Or as: [Energy (in Ws) / Time (in s)]
|
||||||
|
} else if sc.MetricConfig[i].Energy == "power" {
|
||||||
// This assumes the metric is of aggregation type sum
|
// This assumes the metric is of aggregation type sum
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
let carbonMass;
|
let carbonMass;
|
||||||
|
|
||||||
$: if (carbonPerkWh) {
|
$: if (carbonPerkWh) {
|
||||||
// (( Wh / 1000 )* g/kWh) / 1000 = kg || Rounded to 2 Digits via [ round(x * 100) / 100 ]
|
// ( kWh * g/kWh) / 1000 = kg || Rounded to 2 Digits via [ round(x * 100) / 100 ]
|
||||||
carbonMass = round( (((jobEnergy ? jobEnergy : 0.0) / 1000 ) * carbonPerkWh) / 10 ) / 100;
|
carbonMass = round( ((jobEnergy ? jobEnergy : 0.0) * carbonPerkWh) / 10 ) / 100;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<Icon name="plug-fill" style="font-size: 1.5rem;"/>
|
<Icon name="plug-fill" style="font-size: 1.5rem;"/>
|
||||||
</div>
|
</div>
|
||||||
<hr class="mt-0 mb-1"/>
|
<hr class="mt-0 mb-1"/>
|
||||||
<div class="mr-2"><b>{efp.hardware}:</b> {efp.value} Wh (<i>{efp.metric}</i>)</div>
|
<div class="mr-2"><b>{efp.hardware}:</b> {efp.value} kWh (<i>{efp.metric}</i>)</div>
|
||||||
</Col>
|
</Col>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
target={`energy-footprint-${jobId}-${efp.hardware}`}
|
target={`energy-footprint-${jobId}-${efp.hardware}`}
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<Icon name="lightning-charge-fill" style="font-size: 1.5rem;"/>
|
<Icon name="lightning-charge-fill" style="font-size: 1.5rem;"/>
|
||||||
</div>
|
</div>
|
||||||
<hr class="mt-0 mb-1"/>
|
<hr class="mt-0 mb-1"/>
|
||||||
<div><b>Total Energy:</b> {jobEnergy? jobEnergy : 0} Wh</div>
|
<div><b>Total Energy:</b> {jobEnergy? jobEnergy : 0} kWh</div>
|
||||||
</Col>
|
</Col>
|
||||||
{#if carbonPerkWh}
|
{#if carbonPerkWh}
|
||||||
<Col class="text-center cursor-help" id={`energy-footprint-${jobId}-carbon`}>
|
<Col class="text-center cursor-help" id={`energy-footprint-${jobId}-carbon`}>
|
||||||
|
Loading…
Reference in New Issue
Block a user