Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #2879

Merged
merged 1 commit into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Repositories/Metric/MetricRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function listPointsToday(Metric $metric, $hours = 12)
}

$pointKey = $dateTime->sub(new DateInterval('PT1H'))->format('Y-m-d H:00');

}

return $points->sortBy(function ($point, $key) {
return $key;
});
Expand Down
32 changes: 16 additions & 16 deletions app/Repositories/Metric/MySqlRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public function getPointsSinceMinutes(Metric $metric, $minutes)
{
$queryType = $this->getQueryType($metric);

$points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:%i') 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` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) " .
"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() " .
$points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:%i') 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` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) ".
"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ".
"GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`), MINUTE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
'metricId' => $metric->id,
'minutes' => $minutes,
Expand All @@ -57,12 +57,12 @@ public function getPointsSinceMinutes(Metric $metric, $minutes)
public function getPointsSinceHour(Metric $metric, $hour)
{
$queryType = $this->getQueryType($metric);
$points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:00') 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` >= DATE_SUB(NOW(), INTERVAL :hour HOUR) " .
"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() " .
"GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`) " .
$points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:00') 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` >= DATE_SUB(NOW(), INTERVAL :hour HOUR) ".
"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ".
"GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`) ".
"ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
'metricId' => $metric->id,
'hour' => $hour,
Expand All @@ -82,11 +82,11 @@ public function getPointsSinceHour(Metric $metric, $hour)
public function getPointsSinceDay(Metric $metric, $day)
{
$queryType = $this->getQueryType($metric);
$points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d') 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` >= DATE_SUB(NOW(), INTERVAL :day DAY) " .
"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() " .
$points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d') 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` >= DATE_SUB(NOW(), INTERVAL :day DAY) ".
"AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ".
"GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
'metricId' => $metric->id,
'day' => $day,
Expand Down
36 changes: 18 additions & 18 deletions app/Repositories/Metric/PgSqlRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class PgSqlRepository extends AbstractMetricRepository implements MetricInterfac
public function getPointsSinceMinutes(Metric $metric, $minutes)
{
$queryType = $this->getQueryType($metric);
$points = DB::select("SELECT to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:MI') 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 >= (NOW() - INTERVAL '{$minutes}' MINUTE) " .
"AND {$this->getMetricPointsTable()}.created_at <= NOW() " .
"GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:MI') " .
$points = DB::select("SELECT to_char({$this->getMetricPointsTable()}.created_at, 'YYYY-MM-DD HH24:MI') 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 >= (NOW() - INTERVAL '{$minutes}' MINUTE) ".
"AND {$this->getMetricPointsTable()}.created_at <= NOW() ".
"GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:MI') ".
"ORDER BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:MI')", [
'metricId' => $metric->id,
]);
Expand All @@ -57,12 +57,12 @@ public function getPointsSinceMinutes(Metric $metric, $minutes)
public function getPointsSinceHour(Metric $metric, $hour)
{
$queryType = $this->getQueryType($metric);
$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 " .
"WHERE {$this->getMetricsTable()}.id = :metricId " .
"AND {$this->getMetricPointsTable()}.created_at >= (NOW() - INTERVAL '{$hour}' HOUR) " .
"AND {$this->getMetricPointsTable()}.created_at <= NOW() " .
"GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:00') " .
$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 ".
"WHERE {$this->getMetricsTable()}.id = :metricId ".
"AND {$this->getMetricPointsTable()}.created_at >= (NOW() - INTERVAL '{$hour}' HOUR) ".
"AND {$this->getMetricPointsTable()}.created_at <= NOW() ".
"GROUP BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:00') ".
"ORDER BY to_char({$this->getMetricPointsTable()}.created_at, 'HH24:00')", [
'metricId' => $metric->id,
]);
Expand All @@ -81,12 +81,12 @@ public function getPointsSinceHour(Metric $metric, $hour)
public function getPointsSinceDay(Metric $metric, $day)
{
$queryType = $this->getQueryType($metric);
$points = DB::select("SELECT DATE({$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 >= (DATE(NOW()) - INTERVAL '{$day}' DAY) " .
"AND {$this->getMetricPointsTable()}.created_at <= DATE(NOW()) " .
"GROUP BY DATE({$this->getMetricPointsTable()}.created_at) " .
$points = DB::select("SELECT DATE({$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 >= (DATE(NOW()) - INTERVAL '{$day}' DAY) ".
"AND {$this->getMetricPointsTable()}.created_at <= DATE(NOW()) ".
"GROUP BY DATE({$this->getMetricPointsTable()}.created_at) ".
"ORDER BY DATE({$this->getMetricPointsTable()}.created_at)", [
'metricId' => $metric->id,
]);
Expand Down
36 changes: 18 additions & 18 deletions app/Repositories/Metric/SqliteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand All @@ -58,11 +58,11 @@ public function getPointsSinceMinutes(Metric $metric, $minutes)
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,
]);
Expand All @@ -81,12 +81,12 @@ public function getPointsSinceHour(Metric $metric, $hour)
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,
]);
Expand Down