feat: add map analytics, add episodes analytics, clean analytics page layout, translate countries

This commit is contained in:
Benjamin Bellamy 2020-10-14 10:38:48 +00:00 committed by Yassine Doghri
commit 07eae83a00
27 changed files with 705 additions and 192 deletions

View file

@ -32,11 +32,16 @@ class AnalyticsPodcastByRegionModel extends Model
*/
public function getData(int $podcastId): array
{
if (!($found = cache("{$podcastId}_analytics_podcast_by_region"))) {
$locale = service('request')->getLocale();
if (
!($found = cache(
"{$podcastId}_analytics_podcast_by_region_{$locale}"
))
) {
$found = $this->select(
'`country_code`, `region_code`, `latitude`, `longitude`'
)
->selectSum('`hits`', '`values`')
->selectSum('`hits`', '`value`')
->groupBy(
'`country_code`, `region_code`, `latitude`, `longitude`'
)
@ -44,11 +49,11 @@ class AnalyticsPodcastByRegionModel extends Model
'`podcast_id`' => $podcastId,
'`date` >' => date('Y-m-d', strtotime('-1 week')),
])
->orderBy('`values`', 'DESC')
->orderBy('`value`', 'DESC')
->findAll();
cache()->save(
"{$podcastId}_analytics_podcast_by_region",
"{$podcastId}_analytics_podcast_by_region_{$locale}",
$found,
600
);