From 28efac60f72ebe44c55232593bb36b5bd47ea5ba Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Sun, 5 May 2024 09:42:12 +0100 Subject: [PATCH 01/10] added new Top Plays --- css/topnav.css | 2 +- engine/IPlaylist.php | 4 +-- engine/impl/Playlist.php | 23 +++++++++--- ui/Playlists.php | 16 ++++++++- ui/templates/default/airplay.html | 58 +++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 ui/templates/default/airplay.html diff --git a/css/topnav.css b/css/topnav.css index 4c5975a4..ddeb1058 100644 --- a/css/topnav.css +++ b/css/topnav.css @@ -196,7 +196,7 @@ nav .search-icon { position: absolute; display: block; left: 0; - margin-right: -150px;/* TBD fix me */ + margin-right: -200px;/* TBD fix me */ } .nav-items:not(.active) li.selected ul li { float: left; diff --git a/engine/IPlaylist.php b/engine/IPlaylist.php index adfeef3b..89832f25 100644 --- a/engine/IPlaylist.php +++ b/engine/IPlaylist.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -98,7 +98,7 @@ function updateTrack($playlistId, $id, $tag, $artist, $track, $album, $label, $d function insertTrackEntry($playlistId, PlaylistEntry $entry, &$status); function updateTrackEntry($playlist, PlaylistEntry $entry); function deleteTrack($id); - function getTopPlays($airname=0, $days=41, $count=10); + function getTopPlays($airname=0, $days=41, $count=10, $excludeAutomation=true); function getLastPlays($tag, $count=0, $excludeAutomation=true, $excludeRebroadcasts=true); function getRecentPlays($airname, $count); function getPlaysBefore($timestamp, $limit); diff --git a/engine/impl/Playlist.php b/engine/impl/Playlist.php index ea01ecb6..2792c1d3 100644 --- a/engine/impl/Playlist.php +++ b/engine/impl/Playlist.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -836,13 +836,25 @@ public function deleteTrack($id) { return $success; } - public function getTopPlays($airname=0, $days=41, $count=10) { + public function getTopPlays($airname=0, $days=41, $count=10, $excludeAutomation=true) { + // if constraining by airname, no need to exclude automation + $excludeAutomation &= !$airname; + $zootopia = $excludeAutomation ? $this->getZootopiaAirname() : null; + if($zootopia) { + if(!is_array($zootopia)) + $zootopia = [ $zootopia ]; + + $zootopiaSet = str_repeat("?,", count($zootopia) - 1) . "?"; + } + $over = $airname?"distinct t.list":"*"; - $query = "SELECT t.tag, count($over) plays, l.showdate, IFNULL(a.artist, t.artist) artist, t.album, t.label, count(*)" . + $query = "SELECT max(t.tag) tag, count($over) plays, l.showdate, IFNULL(a.artist, t.artist) artist, t.album, t.label, count(*)" . " FROM tracks t JOIN lists l ON t.list = l.id " . + ($zootopia ? " LEFT JOIN airnames n ON l.airname = n.id " : "") . " LEFT JOIN albumvol a ON a.tag = t.tag " . " WHERE t.artist NOT LIKE '".IPlaylist::SPECIAL_TRACK."%' AND". - " t.album <> '' AND t.label <> '' AND"; + " t.album <> '' AND t.label <> '' AND" . + ($zootopia ? " n.airname NOT IN ($zootopiaSet) AND" : "") ; if($airname) $query .= " l.airname = ? AND"; if($days) @@ -850,6 +862,9 @@ public function getTopPlays($airname=0, $days=41, $count=10) { $query .= " GROUP BY t.album, t.label ORDER BY 2 DESC, 7 DESC, t.artist LIMIT ?"; $stmt = $this->prepare($query); $p = 1; + if($zootopia) + foreach($zootopia as $zka) + $stmt->bindValue($p++, $zka); if($airname) $stmt->bindValue($p++, (int)$airname, \PDO::PARAM_INT); $stmt->bindValue($p++, (int)$count, \PDO::PARAM_INT); diff --git a/ui/Playlists.php b/ui/Playlists.php index 1632fdf7..0e1848b2 100644 --- a/ui/Playlists.php +++ b/ui/Playlists.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -55,6 +55,7 @@ class Playlists extends MenuItem { [ "u", "editListGetHint", 0, "listManagerGetHint" ], [ "u", "editListEditor", 0, "emitEditor" ], [ "a", "viewDJ", "By DJ", "emitViewDJ" ], + [ "a", "viewTop", "Top Plays", "emitTopPlays" ], [ "u", "import", "Import", "emitImportList" ], ]; @@ -1021,6 +1022,19 @@ public function emitViewDJ() { $this->emitViewDJMain(); } + + public function emitTopPlays() { + $days = min($_REQUEST['days'] ?? 27, 42); + $limit = min($_REQUEST['limit'] ?? 30, 100); + + $topPlays = Engine::api(IPlaylist::class)->getTopPlays(0, $days, $limit); + Engine::api(ILibrary::class)->markAlbumsReviewed($topPlays); + + $this->setTemplate('airplay.html'); + $this->addVar('days', $days); + $this->addVar('limit', $limit); + $this->addVar('topPlays', $topPlays); + } public function emitViewDJMain() { $viewAll = $this->subaction == "viewDJAll"; diff --git a/ui/templates/default/airplay.html b/ui/templates/default/airplay.html new file mode 100644 index 00000000..f5bac18b --- /dev/null +++ b/ui/templates/default/airplay.html @@ -0,0 +1,58 @@ +{%~ set odays = [7, 14, 30] %} + + From b3812e056d66968c69ae02720d017137b799763b Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Sun, 5 May 2024 09:57:42 +0100 Subject: [PATCH 02/10] fixed default days --- ui/Playlists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/Playlists.php b/ui/Playlists.php index 0e1848b2..6c3c42f5 100644 --- a/ui/Playlists.php +++ b/ui/Playlists.php @@ -1024,7 +1024,7 @@ public function emitViewDJ() { } public function emitTopPlays() { - $days = min($_REQUEST['days'] ?? 27, 42); + $days = min($_REQUEST['days'] ?? 7, 42); $limit = min($_REQUEST['limit'] ?? 30, 100); $topPlays = Engine::api(IPlaylist::class)->getTopPlays(0, $days, $limit); From 7febded54b8c571249dbfa98bac849224b73ac60 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Sun, 5 May 2024 10:22:53 +0100 Subject: [PATCH 03/10] added artist name swapping --- ui/Playlists.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/Playlists.php b/ui/Playlists.php index 6c3c42f5..da45b848 100644 --- a/ui/Playlists.php +++ b/ui/Playlists.php @@ -1030,6 +1030,11 @@ public function emitTopPlays() { $topPlays = Engine::api(IPlaylist::class)->getTopPlays(0, $days, $limit); Engine::api(ILibrary::class)->markAlbumsReviewed($topPlays); + foreach($topPlays as &$entry) { + if($entry['tag'] && substr($entry['artist'], 0, 7) != "[coll]:") + $entry['artist'] = PlaylistEntry::swapNames($entry['artist']); + } + $this->setTemplate('airplay.html'); $this->addVar('days', $days); $this->addVar('limit', $limit); From c4ffac3daa118d173f1b7a19957ab5536d90c149 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Sun, 5 May 2024 10:33:04 +0100 Subject: [PATCH 04/10] optimised compilation detection (non-semantic change) --- engine/impl/Playlist.php | 2 +- ui/Playlists.php | 2 +- ui/templates/default/airplay.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/impl/Playlist.php b/engine/impl/Playlist.php index 2792c1d3..33fc023f 100644 --- a/engine/impl/Playlist.php +++ b/engine/impl/Playlist.php @@ -848,7 +848,7 @@ public function getTopPlays($airname=0, $days=41, $count=10, $excludeAutomation= } $over = $airname?"distinct t.list":"*"; - $query = "SELECT max(t.tag) tag, count($over) plays, l.showdate, IFNULL(a.artist, t.artist) artist, t.album, t.label, count(*)" . + $query = "SELECT max(t.tag) tag, count($over) plays, l.showdate, IFNULL(a.artist, t.artist) artist, t.album, t.label, count(*), a.iscoll" . " FROM tracks t JOIN lists l ON t.list = l.id " . ($zootopia ? " LEFT JOIN airnames n ON l.airname = n.id " : "") . " LEFT JOIN albumvol a ON a.tag = t.tag " . diff --git a/ui/Playlists.php b/ui/Playlists.php index da45b848..870fb6f7 100644 --- a/ui/Playlists.php +++ b/ui/Playlists.php @@ -1031,7 +1031,7 @@ public function emitTopPlays() { Engine::api(ILibrary::class)->markAlbumsReviewed($topPlays); foreach($topPlays as &$entry) { - if($entry['tag'] && substr($entry['artist'], 0, 7) != "[coll]:") + if($entry['tag'] && !$entry['iscoll']) $entry['artist'] = PlaylistEntry::swapNames($entry['artist']); } diff --git a/ui/templates/default/airplay.html b/ui/templates/default/airplay.html index f5bac18b..9d8ce97b 100644 --- a/ui/templates/default/airplay.html +++ b/ui/templates/default/airplay.html @@ -22,7 +22,7 @@

Top airplay for the last {%~ for index, entry in topPlays %} {{ index + 1}}. - {{ entry.artist starts with '[coll]:' ? "Various Artists" : entry.artist }} + {{ entry.iscoll ? "Various Artists" : entry.artist }} {{ entry.reviewed ? "
" }} {%~ if entry.album | length %} From cf4f356b1800be8236feb3fd03b0518dd3868900 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Sun, 5 May 2024 10:43:45 +0100 Subject: [PATCH 05/10] cleaned up markup (non-semantic change) --- ui/templates/default/airplay.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/templates/default/airplay.html b/ui/templates/default/airplay.html index 9d8ce97b..4e3b89d3 100644 --- a/ui/templates/default/airplay.html +++ b/ui/templates/default/airplay.html @@ -1,20 +1,20 @@ -{%~ set odays = [7, 14, 30] %} +{% set odays = [7, 14, 30] %}