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
Campaigns.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Queries; |
| 4 | |
| 5 | use IAWP_SCOPED\IAWP\Models\Campaign; |
| 6 | use IAWP_SCOPED\IAWP\Query; |
| 7 | use IAWP_SCOPED\IAWP\Statistics\Campaign_Statistics; |
| 8 | class Campaigns extends Table_Data |
| 9 | { |
| 10 | protected function convert_results_to_ids($results) : array |
| 11 | { |
| 12 | return Campaign::convert_campaigns_to_ids($results); |
| 13 | } |
| 14 | protected function convert_results_to_resource_ids(array $results = []) : ?array |
| 15 | { |
| 16 | return Campaign::get_resource_ids_for_campaigns($results); |
| 17 | } |
| 18 | protected function statistics_class() : string |
| 19 | { |
| 20 | return Campaign_Statistics::class; |
| 21 | } |
| 22 | protected function query() : array |
| 23 | { |
| 24 | $rows = Query::query('get_campaigns', ['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(); |
| 25 | return $this->rows_to_campaigns($rows); |
| 26 | } |
| 27 | private function rows_to_campaigns($rows) : array |
| 28 | { |
| 29 | return \array_map(function ($row) { |
| 30 | $row->campaign_ids = \explode(',', $row->campaign_ids); |
| 31 | return new Campaign($row); |
| 32 | }, $rows); |
| 33 | } |
| 34 | } |
| 35 |