PluginProbe
Independent Analytics – WordPress Analytics Plugin / 1.28.3
Independent Analytics – WordPress Analytics Plugin v1.28.3
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Queries / Countries.php
Countries.php
36 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Country_Statistics;
8 class Countries 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 Country_Statistics::class;
17 }
18 protected function query() : array
19 {
20 $rows = Query::query('get_countries', ['start' => $this->date_range()->iso_start(), 'end' => $this->date_range()->iso_end(), 'prev_start' => $this->date_range()->previous_period()->iso_start(), 'prev_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->country_ids));
32 return new Geo($row);
33 }, $rows);
34 }
35 }
36