Loading app/Models/AnalyticsPodcastByCountryModel.php +3 −37 Original line number Diff line number Diff line Loading @@ -46,24 +46,7 @@ class AnalyticsPodcastByCountryModel extends Model ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(9); $found[] = $this->db ->query( "SELECT \"Other\" AS `labels`, SUM(`others`.`values`) AS `values` FROM (SELECT SUM(`hits`) AS `values` FROM {$this->db->prefixTable($this->table)} WHERE `date` > $oneWeekAgo GROUP BY `country_code` ORDER BY `values` DESC LIMIT 18446744073709551610 OFFSET 9 ) AS `others` GROUP BY `labels`" ) ->getRow(0); ->findAll(); cache()->save( "{$podcastId}_analytics_podcast_by_country_weekly", Loading Loading @@ -97,24 +80,7 @@ class AnalyticsPodcastByCountryModel extends Model ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); $found[] = $this->db ->query( "SELECT \"Other\" AS `labels`, SUM(`others`.`values`) AS `values` FROM (SELECT SUM(`hits`) AS `values` FROM {$this->db->prefixTable($this->table)} WHERE `date` > $oneyearago GROUP BY `country_code` ORDER BY `values` DESC LIMIT 18446744073709551610 OFFSET 9 ) AS `others` GROUP BY `labels`" ) ->getRow(0); ->findAll(); cache()->save( "{$podcastId}_analytics_podcast_by_country_yearly", Loading app/Models/AnalyticsPodcastByHourModel.php +3 −6 Original line number Diff line number Diff line Loading @@ -33,7 +33,9 @@ class AnalyticsPodcastByHourModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_podcasts_by_hour"))) { $found = $this->select('`hour` as `labels`') $found = $this->select( 'right(concat(\'0\',`hour`,\'h\'),3) as `labels`' ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, Loading @@ -51,9 +53,4 @@ class AnalyticsPodcastByHourModel extends Model } return $found; } } app/Models/AnalyticsPodcastByPlayerModel.php +18 −17 Original line number Diff line number Diff line Loading @@ -37,18 +37,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_service_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`service` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`service` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_service_weekly", $found, Loading @@ -72,18 +72,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_app_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`app` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`app` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_app_weekly", $found, Loading @@ -107,18 +107,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_app_yearly" )) ) { $oneYearAgo = date('Y-m-d', strtotime('-1 year')); $found = $this->select('`app` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`app` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 year')), '`date` >' => $oneYearAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_app_yearly", $found, Loading @@ -142,6 +142,7 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_os_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`os` as `labels`') ->selectSum('`hits`', '`values`') ->where([ Loading @@ -149,12 +150,11 @@ class AnalyticsPodcastByPlayerModel extends Model '`app` !=' => '', '`os` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_os_weekly", $found, Loading @@ -178,18 +178,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_device_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`device` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`device` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_device_weekly", $found, Loading @@ -211,16 +211,17 @@ class AnalyticsPodcastByPlayerModel extends Model if ( !($found = cache("{$podcastId}_analytics_podcasts_by_player_bots")) ) { $oneYearAgo = date('Y-m-d', strtotime('-1 year')); $found = $this->select('DATE_FORMAT(`date`,"%Y-%m-01") as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`is_bot`' => 1, '`date` >' => date('Y-m-d', strtotime('-1 year')), '`date` >' => $oneYearAgo, ]) ->groupBy('`labels`') ->orderBy('`labels`', 'ASC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_bots", Loading app/Models/AnalyticsWebsiteByBrowserModel.php +3 −3 Original line number Diff line number Diff line Loading @@ -33,16 +33,16 @@ class AnalyticsWebsiteByBrowserModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_website_by_browser"))) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`browser` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_website_by_browser", $found, Loading app/Models/AnalyticsWebsiteByEntryPageModel.php +3 −3 Original line number Diff line number Diff line Loading @@ -33,18 +33,18 @@ class AnalyticsWebsiteByEntryPageModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_website_by_entry_page"))) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select( 'IF(`entry_page_url`=\'/\',\'/\',SUBSTRING_INDEX(`entry_page_url`,\'/\',-1)) as `labels`' ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_website_by_entry_page", $found, Loading Loading
app/Models/AnalyticsPodcastByCountryModel.php +3 −37 Original line number Diff line number Diff line Loading @@ -46,24 +46,7 @@ class AnalyticsPodcastByCountryModel extends Model ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(9); $found[] = $this->db ->query( "SELECT \"Other\" AS `labels`, SUM(`others`.`values`) AS `values` FROM (SELECT SUM(`hits`) AS `values` FROM {$this->db->prefixTable($this->table)} WHERE `date` > $oneWeekAgo GROUP BY `country_code` ORDER BY `values` DESC LIMIT 18446744073709551610 OFFSET 9 ) AS `others` GROUP BY `labels`" ) ->getRow(0); ->findAll(); cache()->save( "{$podcastId}_analytics_podcast_by_country_weekly", Loading Loading @@ -97,24 +80,7 @@ class AnalyticsPodcastByCountryModel extends Model ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); $found[] = $this->db ->query( "SELECT \"Other\" AS `labels`, SUM(`others`.`values`) AS `values` FROM (SELECT SUM(`hits`) AS `values` FROM {$this->db->prefixTable($this->table)} WHERE `date` > $oneyearago GROUP BY `country_code` ORDER BY `values` DESC LIMIT 18446744073709551610 OFFSET 9 ) AS `others` GROUP BY `labels`" ) ->getRow(0); ->findAll(); cache()->save( "{$podcastId}_analytics_podcast_by_country_yearly", Loading
app/Models/AnalyticsPodcastByHourModel.php +3 −6 Original line number Diff line number Diff line Loading @@ -33,7 +33,9 @@ class AnalyticsPodcastByHourModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_podcasts_by_hour"))) { $found = $this->select('`hour` as `labels`') $found = $this->select( 'right(concat(\'0\',`hour`,\'h\'),3) as `labels`' ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, Loading @@ -51,9 +53,4 @@ class AnalyticsPodcastByHourModel extends Model } return $found; } }
app/Models/AnalyticsPodcastByPlayerModel.php +18 −17 Original line number Diff line number Diff line Loading @@ -37,18 +37,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_service_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`service` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`service` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_service_weekly", $found, Loading @@ -72,18 +72,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_app_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`app` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`app` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_app_weekly", $found, Loading @@ -107,18 +107,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_app_yearly" )) ) { $oneYearAgo = date('Y-m-d', strtotime('-1 year')); $found = $this->select('`app` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`app` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 year')), '`date` >' => $oneYearAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_app_yearly", $found, Loading @@ -142,6 +142,7 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_os_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`os` as `labels`') ->selectSum('`hits`', '`values`') ->where([ Loading @@ -149,12 +150,11 @@ class AnalyticsPodcastByPlayerModel extends Model '`app` !=' => '', '`os` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_os_weekly", $found, Loading @@ -178,18 +178,18 @@ class AnalyticsPodcastByPlayerModel extends Model "{$podcastId}_analytics_podcasts_by_player_by_device_weekly" )) ) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`device` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`device` !=' => '', '`is_bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_by_device_weekly", $found, Loading @@ -211,16 +211,17 @@ class AnalyticsPodcastByPlayerModel extends Model if ( !($found = cache("{$podcastId}_analytics_podcasts_by_player_bots")) ) { $oneYearAgo = date('Y-m-d', strtotime('-1 year')); $found = $this->select('DATE_FORMAT(`date`,"%Y-%m-01") as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`is_bot`' => 1, '`date` >' => date('Y-m-d', strtotime('-1 year')), '`date` >' => $oneYearAgo, ]) ->groupBy('`labels`') ->orderBy('`labels`', 'ASC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_podcasts_by_player_bots", Loading
app/Models/AnalyticsWebsiteByBrowserModel.php +3 −3 Original line number Diff line number Diff line Loading @@ -33,16 +33,16 @@ class AnalyticsWebsiteByBrowserModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_website_by_browser"))) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select('`browser` as `labels`') ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_website_by_browser", $found, Loading
app/Models/AnalyticsWebsiteByEntryPageModel.php +3 −3 Original line number Diff line number Diff line Loading @@ -33,18 +33,18 @@ class AnalyticsWebsiteByEntryPageModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_website_by_entry_page"))) { $oneWeekAgo = date('Y-m-d', strtotime('-1 week')); $found = $this->select( 'IF(`entry_page_url`=\'/\',\'/\',SUBSTRING_INDEX(`entry_page_url`,\'/\',-1)) as `labels`' ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, '`date` >' => date('Y-m-d', strtotime('-1 week')), '`date` >' => $oneWeekAgo, ]) ->groupBy('`labels`') ->orderBy('`values`', 'DESC') ->findAll(10); ->findAll(); cache()->save( "{$podcastId}_analytics_website_by_entry_page", $found, Loading