Skip to content

Commit

Permalink
Merge pull request #170 from josepico01/Issue#168
Browse files Browse the repository at this point in the history
Issue #168: Fix metric identifiers in chart API to remain unchanged
  • Loading branch information
cameron1729 committed Apr 23, 2024
2 parents 2024141 + ee6a2f0 commit 7420003
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions collector/database/classes/collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ public function get_metrics_aggregated($metricnames = null, $since = false, int
}

if ($aggregate == DAYSECS) {
$incrementstart = "date as increment_start";
$incrementstart = "date AS increment_start";
} else {
$incrementstart = "FLOOR(time/$aggregate) * $aggregate as increment_start";
$incrementstart = "FLOOR(time/$aggregate) * $aggregate AS increment_start";
}
list ($clause, $params) = $DB->get_in_or_equal($metricnames);
if (count($metricnames) == 1) {
$sql = "SELECT AVG(" . $DB->sql_cast_char2int('value', true) . ") as $metricnames[0],
MIN(" . $DB->sql_cast_char2int('value', true) . ") as min,
MAX(" . $DB->sql_cast_char2int('value', true) . ") as max,
$sql = "SELECT AVG(" . $DB->sql_cast_char2int('value', true) . ") AS \"$metricnames[0]\",
MIN(" . $DB->sql_cast_char2int('value', true) . ") AS min,
MAX(" . $DB->sql_cast_char2int('value', true) . ") AS max,
$incrementstart
FROM {cltr_database_metrics}
WHERE name $clause
Expand All @@ -143,7 +143,7 @@ public function get_metrics_aggregated($metricnames = null, $since = false, int
} else {
$metricselect = '';
foreach ($params as $param) {
$metricselect .= "AVG(CASE name WHEN '$param' THEN" . $DB->sql_cast_char2int('value', true) . "END) $param,";
$metricselect .= "AVG(CASE name WHEN '$param' THEN" . $DB->sql_cast_char2int('value', true) . "END) AS \"$param\",";
}
$metricselect = rtrim($metricselect, ',');
$sql = "SELECT $incrementstart,
Expand Down

0 comments on commit 7420003

Please sign in to comment.