From 4c6aeb1a6ea53acbe662060a7b6411bb9850301c Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Mon, 11 Jul 2016 21:12:02 +0100 Subject: [PATCH] #86: Updated stats API to work with Postgres --- app/Http/Controllers/Api/Web/StatsController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/Web/StatsController.php b/app/Http/Controllers/Api/Web/StatsController.php index c9672713..e7e05a6c 100644 --- a/app/Http/Controllers/Api/Web/StatsController.php +++ b/app/Http/Controllers/Api/Web/StatsController.php @@ -33,17 +33,17 @@ use Carbon\Carbon; class StatsController extends ApiControllerBase { private function getStatsData($id, $hourly = false) { - $playRange = "1 MONTH"; + $playRange = "'1 MONTH'"; if ($hourly) { - $playRange = "2 DAY"; + $playRange = "'2 DAY'"; } $statQuery = DB::table('resource_log_items') - ->selectRaw('created_at, COUNT(1) AS `plays`') + ->selectRaw('created_at, COUNT(1) AS "plays"') ->where('track_id', '=', $id) ->where('log_type', '=', ResourceLogItem::PLAY) - ->whereRaw('`created_at` > now() - INTERVAL '.$playRange) + ->whereRaw('"created_at" > now() - INTERVAL '.$playRange) ->groupBy('created_at') ->orderBy('created_at') ->get();