feat(public-ui): adapt public podcast and episode pages to wireframes

- adapt wireframes with responsive design
- refactor models methods to cache requests for faster queries
- update public controllers to cache pages while retaining analytics hits
- add platform links to podcast page
- add previous / next episodes in episode page
- update npm packages to latest versions

closes #30, #13
This commit is contained in:
Yassine Doghri 2020-09-04 09:09:26 +00:00
commit 40a0535fc1
32 changed files with 2058 additions and 1474 deletions

View file

@ -36,21 +36,49 @@ class PlatformModel extends Model
protected $useTimestamps = true;
public function getPlatformsWithLinks()
public function getPlatformsWithLinks($podcastId)
{
return $this->select(
'platforms.*, platform_links.link_url, platform_links.visible'
)
->join(
'platform_links',
'platform_links.platform_id = platforms.id',
'left'
if (!($found = cache("podcast{$podcastId}_platforms"))) {
$found = $this->select(
'platforms.*, platform_links.link_url, platform_links.visible'
)
->findAll();
->join(
'platform_links',
"platform_links.platform_id = platforms.id AND platform_links.podcast_id = $podcastId",
'left'
)
->findAll();
cache()->save("podcast{$podcastId}_platforms", $found, DECADE);
}
return $found;
}
public function getPodcastPlatformLinks($podcastId)
{
if (!($found = cache("podcast{$podcastId}_platformLinks"))) {
$found = $this->select(
'platforms.*, platform_links.link_url, platform_links.visible'
)
->join(
'platform_links',
'platform_links.platform_id = platforms.id'
)
->where('platform_links.podcast_id', $podcastId)
->findAll();
cache()->save("podcast{$podcastId}_platformLinks", $found, DECADE);
}
return $found;
}
public function savePlatformLinks($podcastId, $platformLinksData)
{
cache()->delete("podcast{$podcastId}_platforms");
cache()->delete("podcast{$podcastId}_platformLinks");
// Remove already previously set platforms to overwrite them
$this->db
->table('platform_links')
@ -81,6 +109,9 @@ class PlatformModel extends Model
public function removePlatformLink($podcastId, $platformId)
{
cache()->delete("podcast{$podcastId}_platforms");
cache()->delete("podcast{$podcastId}_platformLinks");
return $this->db->table('platform_links')->delete([
'podcast_id' => $podcastId,
'platform_id' => $platformId,