Redundancy filter

This commit is contained in:
Daniel Brendel
2023-03-25 15:50:15 +01:00
parent ddd7a59987
commit f8869899ef
4 changed files with 16 additions and 10 deletions

View File

@ -92,11 +92,20 @@ class HitsModel extends \Asatru\Database\Model
public static function getReferrers($start, $end)
{
try {
$result = 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 FROM `' . self::tableName() . '` WHERE DATE(created_at) >= ? AND DATE(created_at) <= ? ORDER BY referrer ASC', [
$start,
$end
]);
$result = [];
foreach ($items as $item) {
$furl = parse_url($item->get('referrer'), PHP_URL_HOST);
if (!in_array($furl, $result)) {
$result[] = $furl;
}
}
return $result;
} catch (\Exception $e) {
throw $e;