Statistieken werkend
This commit is contained in:
@@ -84,6 +84,37 @@ QUERY;
|
|||||||
return response()->json($result);
|
return response()->json($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populaire berichten ophalen
|
||||||
|
*/
|
||||||
|
public function popular(Request $request) {
|
||||||
|
$count = (int)$request->get('aantal', 5);
|
||||||
|
$recent = app('db')->select(<<<QUERY
|
||||||
|
SELECT `type`, `item_id`, COUNT(DISTINCT session) AS `count`
|
||||||
|
FROM pagestats
|
||||||
|
WHERE `type` = 'nieuws' AND `timestamp` > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY)
|
||||||
|
GROUP BY `item_id`
|
||||||
|
ORDER BY `count` DESC
|
||||||
|
LIMIT 0, :count
|
||||||
|
QUERY
|
||||||
|
, [
|
||||||
|
'count' => $count
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json($recent);
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
foreach($recent as $item)
|
||||||
|
{
|
||||||
|
$newsItem = app('db')->select(self::$BASE_SQL . ' AND `news`.`id` = :newsId', ['newsId' => $item->item_id])[0];
|
||||||
|
$pictures = app('db')->select(self::$LOAD_IMAGES, ['newsId' => $newsItem->id]);
|
||||||
|
$result[] = new \Model\NewsItem($newsItem, $pictures);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifiek nieuwsbericht ophalen
|
* Specifiek nieuwsbericht ophalen
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ $app->get('/', function () use ($app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$app->get('nieuws/overzicht', 'NewsController@newslist' );
|
$app->get('nieuws/overzicht', 'NewsController@newslist' );
|
||||||
|
$app->get('nieuws/populair', 'NewsController@popular' );
|
||||||
$app->get('nieuws/bericht/{id:\d+}', 'NewsController@newsitem' );
|
$app->get('nieuws/bericht/{id:\d+}', 'NewsController@newsitem' );
|
||||||
$app->get('nieuws/regionieuws', 'PodcastController@latestNews' );
|
$app->get('nieuws/regionieuws', 'PodcastController@latestNews' );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user