mirror of
https://github.com/SophiaAtkinson/steamwidgets-web.git
synced 2025-06-27 12:27:42 -07:00
Referrer count
This commit is contained in:
@ -92,7 +92,7 @@ class HitsModel extends \Asatru\Database\Model
|
||||
public static function getReferrers($start, $end)
|
||||
{
|
||||
try {
|
||||
$items = HitsModel::raw('SELECT DISTINCT referrer FROM `' . self::tableName() . '` WHERE DATE(created_at) >= ? AND DATE(created_at) <= ? ORDER BY referrer ASC', [
|
||||
$items = HitsModel::raw('SELECT DISTINCT referrer, COUNT(referrer) AS count FROM `' . self::tableName() . '` WHERE DATE(created_at) >= ? AND DATE(created_at) <= ? GROUP BY referrer ORDER BY referrer ASC', [
|
||||
$start,
|
||||
$end
|
||||
]);
|
||||
@ -102,10 +102,12 @@ class HitsModel extends \Asatru\Database\Model
|
||||
foreach ($items as $item) {
|
||||
$furl = parse_url($item->get('referrer'), PHP_URL_HOST);
|
||||
if (!in_array($furl, $result)) {
|
||||
$result[] = $furl;
|
||||
$entry['ref'] = $furl;
|
||||
$entry['count'] = $item->get('count');
|
||||
$result[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
Reference in New Issue
Block a user