mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
#86: Updated stats API to work with Postgres
This commit is contained in:
parent
a57c1640e8
commit
4c6aeb1a6e
1 changed files with 4 additions and 4 deletions
|
@ -33,17 +33,17 @@ use Carbon\Carbon;
|
||||||
class StatsController extends ApiControllerBase
|
class StatsController extends ApiControllerBase
|
||||||
{
|
{
|
||||||
private function getStatsData($id, $hourly = false) {
|
private function getStatsData($id, $hourly = false) {
|
||||||
$playRange = "1 MONTH";
|
$playRange = "'1 MONTH'";
|
||||||
|
|
||||||
if ($hourly) {
|
if ($hourly) {
|
||||||
$playRange = "2 DAY";
|
$playRange = "'2 DAY'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$statQuery = DB::table('resource_log_items')
|
$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('track_id', '=', $id)
|
||||||
->where('log_type', '=', ResourceLogItem::PLAY)
|
->where('log_type', '=', ResourceLogItem::PLAY)
|
||||||
->whereRaw('`created_at` > now() - INTERVAL '.$playRange)
|
->whereRaw('"created_at" > now() - INTERVAL '.$playRange)
|
||||||
->groupBy('created_at')
|
->groupBy('created_at')
|
||||||
->orderBy('created_at')
|
->orderBy('created_at')
|
||||||
->get();
|
->get();
|
||||||
|
|
Loading…
Reference in a new issue