Merge pull request #2959 from JordyvanDortmont/sqlite3

Fix SQLite metric points retrieval datetime
This commit is contained in:
James Brooks
2018-03-26 20:08:16 +01:00
committed by GitHub

View File

@@ -37,8 +37,8 @@ class SqliteRepository extends AbstractMetricRepository implements MetricInterfa
"FROM {$this->getMetricsTable()} ".
"INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ".
"WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.`created_at` >= datetime('now', '-{$minutes} minutes') ".
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now') ".
"AND {$this->getMetricPointsTable()}.`created_at` >= datetime('now', 'localtime', '-{$minutes} minutes') ".
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now', 'localtime') ".
"GROUP BY strftime('%H', {$this->getMetricPointsTable()}.`created_at`), strftime('%M', {$this->getMetricPointsTable()}.`created_at`) ".
"ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
'metricId' => $metric->id,
@@ -61,8 +61,8 @@ class SqliteRepository extends AbstractMetricRepository implements MetricInterfa
$points = DB::select("SELECT strftime('%Y-%m-%d %H:00', {$this->getMetricPointsTable()}.`created_at`) AS `key`, {$queryType} ".
"FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ".
"WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.`created_at` >= datetime('now', '-{$hour} hours') ".
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now') ".
"AND {$this->getMetricPointsTable()}.`created_at` >= datetime('now', 'localtime', '-{$hour} hours') ".
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now', 'localtime') ".
"GROUP BY strftime('%H', {$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
'metricId' => $metric->id,
]);
@@ -84,8 +84,8 @@ class SqliteRepository extends AbstractMetricRepository implements MetricInterfa
$points = DB::select("SELECT strftime('%Y-%m-%d', {$this->getMetricPointsTable()}.`created_at`) AS `key`, {$queryType} ".
"FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ".
"WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.`created_at` >= datetime('now', '-{$day} days') ".
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now') ".
"AND {$this->getMetricPointsTable()}.`created_at` >= datetime('now', 'localtime', '-{$day} days') ".
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now', 'localtime') ".
"GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ".
"ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
'metricId' => $metric->id,