Fixing issue to be able to have mterics work for recommended docker / postgresql setup

This commit is contained in:
Marek Knappe
2020-05-20 14:51:07 +10:00
parent c7ad51e876
commit 367c1dd31f

View File

@@ -37,8 +37,8 @@ class PgSqlRepository extends AbstractMetricRepository implements MetricInterfac
"WHERE {$this->getMetricsTable()}.id = :metricId ". "WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.created_at >= (NOW() - INTERVAL '{$minutes}' MINUTE) ". "AND {$this->getMetricPointsTable()}.created_at >= (NOW() - INTERVAL '{$minutes}' MINUTE) ".
"AND {$this->getMetricPointsTable()}.created_at <= NOW() ". "AND {$this->getMetricPointsTable()}.created_at <= NOW() ".
"GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:MI') ". "GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:MI') ".
"ORDER BY {$this->getMetricPointsTable()}.created_at", [ "ORDER BY to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:MI')", [
'metricId' => $metric->id, 'metricId' => $metric->id,
]); ]);
@@ -61,8 +61,8 @@ class PgSqlRepository extends AbstractMetricRepository implements MetricInterfac
"WHERE {$this->getMetricsTable()}.id = :metricId ". "WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.created_at >= (NOW() - INTERVAL '{$hour}' HOUR) ". "AND {$this->getMetricPointsTable()}.created_at >= (NOW() - INTERVAL '{$hour}' HOUR) ".
"AND {$this->getMetricPointsTable()}.created_at <= NOW() ". "AND {$this->getMetricPointsTable()}.created_at <= NOW() ".
"GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:00') ". "GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:00') ".
"ORDER BY {$this->getMetricPointsTable()}.created_at", [ "ORDER BY to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:00')", [
'metricId' => $metric->id, 'metricId' => $metric->id,
]); ]);
@@ -80,13 +80,13 @@ class PgSqlRepository extends AbstractMetricRepository implements MetricInterfac
public function getPointsSinceDay(Metric $metric, $day) public function getPointsSinceDay(Metric $metric, $day)
{ {
$queryType = $this->getQueryType($metric); $queryType = $this->getQueryType($metric);
$points = DB::select("SELECT DATE({$this->getMetricPointsTable()}.created_at) AS key, {$queryType} ". $points = DB::select("SELECT to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:00') AS key, {$queryType} ".
"FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ". "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ".
"WHERE {$this->getMetricsTable()}.id = :metricId ". "WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.created_at >= (DATE(NOW()) - INTERVAL '{$day}' DAY) ". "AND {$this->getMetricPointsTable()}.created_at >= (DATE(NOW()) - INTERVAL '{$day}' DAY) ".
"AND {$this->getMetricPointsTable()}.created_at <= DATE(NOW()) ". "AND {$this->getMetricPointsTable()}.created_at <= DATE(NOW()) ".
"GROUP BY DATE({$this->getMetricPointsTable()}.created_at) ". "GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:00')".
"ORDER BY DATE({$this->getMetricPointsTable()}.created_at)", [ "ORDER BY to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:00')", [
'metricId' => $metric->id, 'metricId' => $metric->id,
]); ]);