@@ -33,13 +33,13 @@ class SqliteRepository extends AbstractMetricRepository implements MetricInterfa
|
||||
public function getPointsSinceMinutes(Metric $metric, $minutes)
|
||||
{
|
||||
$queryType = $this->getQueryType($metric);
|
||||
$points = DB::select("SELECT strftime('%Y-%m-%d %H:%M', {$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', '-{$minutes} minutes') " .
|
||||
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now') " .
|
||||
"GROUP BY strftime('%H', {$this->getMetricPointsTable()}.`created_at`), strftime('%M', {$this->getMetricPointsTable()}.`created_at`) " .
|
||||
$points = DB::select("SELECT strftime('%Y-%m-%d %H:%M', {$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', '-{$minutes} minutes') ".
|
||||
"AND {$this->getMetricPointsTable()}.`created_at` <= datetime('now') ".
|
||||
"GROUP BY strftime('%H', {$this->getMetricPointsTable()}.`created_at`), strftime('%M', {$this->getMetricPointsTable()}.`created_at`) ".
|
||||
"ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
|
||||
'metricId' => $metric->id,
|
||||
]);
|
||||
@@ -58,11 +58,11 @@ class SqliteRepository extends AbstractMetricRepository implements MetricInterfa
|
||||
public function getPointsSinceHour(Metric $metric, $hour)
|
||||
{
|
||||
$queryType = $this->getQueryType($metric);
|
||||
$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') " .
|
||||
$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') ".
|
||||
"GROUP BY strftime('%H', {$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
|
||||
'metricId' => $metric->id,
|
||||
]);
|
||||
@@ -81,12 +81,12 @@ class SqliteRepository extends AbstractMetricRepository implements MetricInterfa
|
||||
public function getPointsSinceDay(Metric $metric, $day)
|
||||
{
|
||||
$queryType = $this->getQueryType($metric);
|
||||
$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') " .
|
||||
"GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) " .
|
||||
$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') ".
|
||||
"GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ".
|
||||
"ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
|
||||
'metricId' => $metric->id,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user