mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Metrics: Calculation set to average always sums
This commit is two part: 1. getActiveValueAttribute should always return the active attribute without providing an average since the active is the current value. 2. The query to create the average was incorrect and was taking the count value * the value which we are really looking for the average of the value.
This commit is contained in:
parent
0b382fd9e3
commit
4e2c6bce0d
@ -83,8 +83,6 @@ class MetricPoint extends Model implements HasPresenter
|
|||||||
{
|
{
|
||||||
if ($this->metric->calc_type === Metric::CALC_SUM) {
|
if ($this->metric->calc_type === Metric::CALC_SUM) {
|
||||||
return round((float) $value * $this->counter, $this->metric->places);
|
return round((float) $value * $this->counter, $this->metric->places);
|
||||||
} elseif ($this->metric->calc_type === Metric::CALC_AVG) {
|
|
||||||
return round((float) $value * $this->counter, $this->metric->places);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return round((float) $value, $this->metric->places);
|
return round((float) $value, $this->metric->places);
|
||||||
|
@ -85,7 +85,7 @@ abstract class AbstractMetricRepository
|
|||||||
if (!isset($metric->calc_type) || $metric->calc_type == Metric::CALC_SUM) {
|
if (!isset($metric->calc_type) || $metric->calc_type == Metric::CALC_SUM) {
|
||||||
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
|
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
|
||||||
} elseif ($metric->calc_type == Metric::CALC_AVG) {
|
} elseif ($metric->calc_type == Metric::CALC_AVG) {
|
||||||
return "avg({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
|
return "avg({$this->getMetricPointsTable()}.value) AS value";
|
||||||
} else {
|
} else {
|
||||||
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
|
return "sum({$this->getMetricPointsTable()}.value * {$this->getMetricPointsTable()}.counter) AS value";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user