-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reverted Top Plays (moved to feature branch)
- Loading branch information
Showing
4 changed files
with
8 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @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, $excludeAutomation=true); | ||
function getTopPlays($airname=0, $days=41, $count=10); | ||
function getLastPlays($tag, $count=0, $excludeAutomation=true, $excludeRebroadcasts=true); | ||
function getRecentPlays($airname, $count); | ||
function getPlaysBefore($timestamp, $limit); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
|
@@ -836,33 +836,20 @@ public function deleteTrack($id) { | |
return $success; | ||
} | ||
|
||
public function getTopPlays($airname=0, $days=41, $count=10, $excludeAutomation=true) { | ||
$zootopia = $excludeAutomation ? $this->getZootopiaAirname() : null; | ||
if($zootopia) { | ||
if(!is_array($zootopia)) | ||
$zootopia = [ $zootopia ]; | ||
|
||
$zootopiaSet = str_repeat("?,", count($zootopia) - 1) . "?"; | ||
} | ||
|
||
public function getTopPlays($airname=0, $days=41, $count=10) { | ||
$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 t.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" . | ||
($zootopia ? " n.airname NOT IN ($zootopiaSet) AND" : "") ; | ||
" t.album <> '' AND t.label <> '' AND"; | ||
if($airname) | ||
$query .= " l.airname = ? AND"; | ||
if($days) | ||
$query .= " date_add(l.showdate, interval $days day) > now() "; | ||
$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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
|
@@ -55,7 +55,6 @@ 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" ], | ||
]; | ||
|
||
|
@@ -1022,64 +1021,6 @@ public function emitViewDJ() { | |
|
||
$this->emitViewDJMain(); | ||
} | ||
|
||
public function emitTopPlays() { | ||
$days = 7; | ||
$limit = 30; | ||
|
||
$topPlays = Engine::api(IPlaylist::class)->getTopPlays(0, $days, $limit); | ||
|
||
if(!sizeof($topPlays)) { | ||
echo " <h2>No top airplay is available</h2>\n"; | ||
return; | ||
} | ||
|
||
echo " <h2>Top airplay for the last $days days</h2>\n"; | ||
echo " <table class='playlistTable' cellpadding='1'>\n"; | ||
echo " <thead>\n"; | ||
echo " <tr class='playlistHdr' align=left><th></th><th>Artist</th><th></th><th>Album/Label</th></tr>"; | ||
echo " </thead>\n"; | ||
|
||
Engine::api(ILibrary::class)->markAlbumsReviewed($topPlays); | ||
$observer = (new PlaylistObserver())->on('spin', function($entry) { | ||
$artist = $entry->getArtist(); | ||
$artistName = $entry->getTag() ? | ||
PlaylistEntry::swapNames( | ||
preg_match("/^\[coll\]:/i", $artist) ? | ||
"Various Artists" : $artist) : | ||
$artist; | ||
$albumName = $entry->getAlbum(); | ||
$labelName = $entry->getLabel(); | ||
|
||
$reviewCell = $entry->getReviewed() ? "<div class='albumReview'></div>" : ""; | ||
|
||
if(!empty($albumName)) { | ||
$albumTitle = $entry->getTag() ? | ||
"<a class='nav' href='?action=search&s=byAlbumKey&n=" . htmlentities($entry->getTag()) . "'>" . htmlentities($albumName) . "</a>" : | ||
UI::smartURL($albumName); | ||
|
||
if(!empty($labelName)) | ||
$albumTitle .= "<span class='songLabel'> / " . UI::smartURL($labelName) . "</span>"; | ||
} else | ||
$albumTitle = ""; | ||
|
||
echo " <tr class='songRow'>" . | ||
"<td>" . htmlentities($entry->getRank()) . ".</td>" . | ||
"<td>" . UI::smartURL($artistName) . "</td>" . | ||
"<td style='width: 15px'>$reviewCell</td>" . | ||
"<td>$albumTitle</td>" . | ||
"</tr>\n"; | ||
}); | ||
|
||
echo " <tbody>\n"; | ||
foreach($topPlays as $rank => $entry) { | ||
$entry['rank'] = $rank + 1; | ||
$observer->observe(new PlaylistEntry($entry)); | ||
} | ||
echo " </tbody>\n </table>\n"; | ||
|
||
echo " <h3>For complete album charting, see our <a href='?action=viewChart'><b>Airplay Charts</b></a></h3>"; | ||
} | ||
|
||
public function emitViewDJMain() { | ||
$viewAll = $this->subaction == "viewDJAll"; | ||
|