diff --git a/app/Controllers/PodcastController.php b/app/Controllers/PodcastController.php index ccc786b3..d113648e 100644 --- a/app/Controllers/PodcastController.php +++ b/app/Controllers/PodcastController.php @@ -125,9 +125,12 @@ class PodcastController extends BaseController ); if (! ($cachedView = cache($cacheName))) { + $stats = (new EpisodeModel())->getPodcastStats($this->podcast->id); + $data = [ 'metatags' => get_podcast_metatags($this->podcast, 'about'), 'podcast' => $this->podcast, + 'stats' => $stats, ]; // // if user is logged in then send to the authenticated activity view diff --git a/app/Language/en/Podcast.php b/app/Language/en/Podcast.php index 7528a9a3..d86ce165 100644 --- a/app/Language/en/Podcast.php +++ b/app/Language/en/Podcast.php @@ -28,12 +28,21 @@ return [ other {# posts} }', 'activity' => 'Activity', - 'activity_title' => '{podcastTitle} news & activity', 'episodes' => 'Episodes', 'episodes_title' => 'Episodes of {podcastTitle}', 'about' => 'About', - 'about_title' => 'About {podcastTitle}', - 'sponsor_title' => 'Enjoying the show?', + 'stats' => [ + 'title' => 'Stats', + 'number_of_seasons' => '{0, plural, + one {# season} + other {# seasons} + }', + 'number_of_episodes' => '{0, plural, + one {# episode} + other {# episodes} + }', + 'first_published_at' => 'First episode published on {0, date, medium}', + ], 'sponsor' => 'Sponsor', 'funding_links' => 'Funding links for {podcastTitle}', 'find_on' => 'Find {podcastTitle} on', diff --git a/app/Language/fr/Podcast.php b/app/Language/fr/Podcast.php index f389e497..bc249c37 100644 --- a/app/Language/fr/Podcast.php +++ b/app/Language/fr/Podcast.php @@ -9,7 +9,7 @@ declare(strict_types=1); */ return [ - 'feed' => 'Podcast RSS feed', + 'feed' => 'Flux RSS Podcast', 'season' => 'Saison {seasonNumber}', 'list_of_episodes_year' => 'Épisodes de {year} ({episodeCount})', 'list_of_episodes_season' => @@ -29,8 +29,19 @@ return [ }', 'activity' => 'Activité', 'episodes' => 'Épisodes', - 'about' => 'About', - 'sponsor_title' => 'Vous aimez le podcast ?', + 'about' => 'À propos', + 'stats' => [ + 'title' => 'Statistiques', + 'number_of_seasons' => '{0, plural, + one {# saison} + other {# saisons} + }', + 'number_of_episodes' => '{0, plural, + one {# épisode} + other {# épisodes} + }', + 'first_published_at' => 'Premier épisode publié le {0, date, medium}', + ], 'sponsor' => 'Soutenez-nous', 'funding_links' => 'Liens de financement pour {podcastTitle}', 'find_on' => 'Trouvez {podcastTitle} sur', diff --git a/app/Models/EpisodeModel.php b/app/Models/EpisodeModel.php index 4edebdec..0e4fa9cf 100644 --- a/app/Models/EpisodeModel.php +++ b/app/Models/EpisodeModel.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace App\Models; use App\Entities\Episode; +use CodeIgniter\I18n\Time; use CodeIgniter\Model; class EpisodeModel extends Model @@ -294,6 +295,33 @@ class EpisodeModel extends Model return (int) $result[0]['next_episode_number'] + 1; } + /** + * @return array + */ + public function getPodcastStats(int $podcastId): array + { + $result = $this->select( + 'COUNT(DISTINCT season_number) as number_of_seasons, COUNT(*) as number_of_episodes, MIN(published_at) as first_published_at' + ) + ->where([ + 'podcast_id' => $podcastId, + 'published_at IS NOT' => null, + $this->deletedField => null, + ])->get() + ->getResultArray(); + + $stats = [ + 'number_of_seasons' => (int) $result[0]['number_of_seasons'], + 'number_of_episodes' => (int) $result[0]['number_of_episodes'], + ]; + + if ($result[0]['first_published_at'] !== null) { + $stats['first_published_at'] = new Time($result[0]['first_published_at']); + } + + return $stats; + } + /** * @param mixed[] $data * diff --git a/modules/Admin/Language/en/Podcast.php b/modules/Admin/Language/en/Podcast.php index 54a5e210..c1cd4cdc 100644 --- a/modules/Admin/Language/en/Podcast.php +++ b/modules/Admin/Language/en/Podcast.php @@ -236,7 +236,6 @@ return [ }', 'activity' => 'Activity', 'episodes' => 'Episodes', - 'sponsor_title' => 'Enjoying the show?', 'sponsor' => 'Sponsor', 'funding_links' => 'Funding links for {podcastTitle}', 'find_on' => 'Find {podcastTitle} on', diff --git a/modules/Admin/Language/fr/Podcast.php b/modules/Admin/Language/fr/Podcast.php index 211e9459..3d207f04 100644 --- a/modules/Admin/Language/fr/Podcast.php +++ b/modules/Admin/Language/fr/Podcast.php @@ -238,7 +238,6 @@ return [ }', 'activity' => 'Activité', 'episodes' => 'Épisodes', - 'sponsor_title' => 'Vous aimez le podcast ?', 'sponsor' => 'Soutenez-nous', 'funding_links' => 'Liens de financement pour {podcastTitle}', 'find_on' => 'Trouvez {podcastTitle} sur', diff --git a/themes/cp_app/podcast/about.php b/themes/cp_app/podcast/about.php index 629577d9..50a27c33 100644 --- a/themes/cp_app/podcast/about.php +++ b/themes/cp_app/podcast/about.php @@ -40,6 +40,16 @@ = location_link($podcast->location, 'text-xs font-semibold p-2') ?> + + = lang('Podcast.stats.title') ?> + + $value): ?> + + = lang('Podcast.about.stats.' . $key, [$value]) ?> + + + +