mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-15 12:37:46 +02:00
feat: add map analytics, add episodes analytics, clean analytics page layout, translate countries
This commit is contained in:
parent
196920d62f
commit
07eae83a00
27 changed files with 705 additions and 192 deletions
|
|
@ -30,9 +30,14 @@ class AnalyticsPodcastByCountryModel extends Model
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData(int $podcastId): array
|
||||
public function getDataWeekly(int $podcastId): array
|
||||
{
|
||||
if (!($found = cache("{$podcastId}_analytics_podcast_by_country"))) {
|
||||
$locale = service('request')->getLocale();
|
||||
if (
|
||||
!($found = cache(
|
||||
"{$podcastId}_analytics_podcast_by_country_weekly_{$locale}"
|
||||
))
|
||||
) {
|
||||
$found = $this->select('`country_code` as `labels`')
|
||||
->selectSum('`hits`', '`values`')
|
||||
->where([
|
||||
|
|
@ -44,7 +49,41 @@ class AnalyticsPodcastByCountryModel extends Model
|
|||
->findAll(10);
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_by_country",
|
||||
"{$podcastId}_analytics_podcast_by_country_weekly_{$locale}",
|
||||
$found,
|
||||
600
|
||||
);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets country data for a podcast
|
||||
*
|
||||
* @param int $podcastId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDataYearly(int $podcastId): array
|
||||
{
|
||||
$locale = service('request')->getLocale();
|
||||
if (
|
||||
!($found = cache(
|
||||
"{$podcastId}_analytics_podcast_by_country_yearly_{$locale}"
|
||||
))
|
||||
) {
|
||||
$found = $this->select('`country_code` as `labels`')
|
||||
->selectSum('`hits`', '`values`')
|
||||
->where([
|
||||
'`podcast_id`' => $podcastId,
|
||||
'`date` >' => date('Y-m-d', strtotime('-1 year')),
|
||||
])
|
||||
->groupBy('`labels`')
|
||||
->orderBy('`values`', 'DESC')
|
||||
->findAll(10);
|
||||
|
||||
cache()->save(
|
||||
"{$podcastId}_analytics_podcast_by_country_yearly_{$locale}",
|
||||
$found,
|
||||
600
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue