Campaigns.php
2 years ago
Cities.php
2 years ago
Countries.php
2 years ago
Current_Traffic_Finder.php
3 years ago
Device_Browsers.php
2 years ago
Device_Operating_Systems.php
2 years ago
Device_Types.php
2 years ago
Referrers.php
2 years ago
Resources.php
2 years ago
Table_Data.php
3 years ago
Visitors_Over_Time_Finder.php
3 years ago
Referrers.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Queries; |
| 4 | |
| 5 | use IAWP_SCOPED\IAWP\Models\Referrer; |
| 6 | use IAWP_SCOPED\IAWP\Query; |
| 7 | use IAWP_SCOPED\IAWP\Statistics\Referrer_Statistics; |
| 8 | class Referrers extends Table_Data |
| 9 | { |
| 10 | protected function convert_results_to_ids($results) : array |
| 11 | { |
| 12 | return Referrer::convert_referrers_to_ids($results); |
| 13 | } |
| 14 | protected function statistics_class() : string |
| 15 | { |
| 16 | return Referrer_Statistics::class; |
| 17 | } |
| 18 | protected function query() : array |
| 19 | { |
| 20 | $rows = Query::query('get_referrers', ['start' => $this->date_range()->iso_start(), 'end' => $this->date_range()->iso_end(), 'previous_start' => $this->date_range()->previous_period()->iso_start(), 'previous_end' => $this->date_range()->previous_period()->iso_end()])->rows(); |
| 21 | return self::rows_to_referrers($rows); |
| 22 | } |
| 23 | private function rows_to_referrers($rows) : array |
| 24 | { |
| 25 | return \array_map(function ($row) { |
| 26 | $has_referrers = !\is_null($row->referrer_ids); |
| 27 | if ($has_referrers) { |
| 28 | $row->referrer_ids = \explode(',', $row->referrer_ids); |
| 29 | } |
| 30 | return new Referrer($row); |
| 31 | }, $rows); |
| 32 | } |
| 33 | } |
| 34 |