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
Cities.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Queries; |
| 4 | |
| 5 | use IAWP_SCOPED\IAWP\Models\Geo; |
| 6 | use IAWP_SCOPED\IAWP\Query; |
| 7 | use IAWP_SCOPED\IAWP\Statistics\City_Statistics; |
| 8 | class Cities extends Table_Data |
| 9 | { |
| 10 | protected function convert_results_to_ids($results) : array |
| 11 | { |
| 12 | return Geo::convert_geos_to_ids($results); |
| 13 | } |
| 14 | protected function statistics_class() : string |
| 15 | { |
| 16 | return City_Statistics::class; |
| 17 | } |
| 18 | protected function query() : array |
| 19 | { |
| 20 | $rows = Query::query('get_cities', ['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_geos($rows); |
| 22 | } |
| 23 | private function rows_to_geos($rows) : array |
| 24 | { |
| 25 | return \array_map(function ($row) { |
| 26 | $row->views = \intval($row->views); |
| 27 | $row->visitors = \intval($row->visitors); |
| 28 | $row->sessions = \intval($row->sessions); |
| 29 | $row->ids = \array_map(function ($id) { |
| 30 | return $id; |
| 31 | }, \explode(',', $row->city_ids)); |
| 32 | return new Geo($row); |
| 33 | }, $rows); |
| 34 | } |
| 35 | } |
| 36 |