We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 3bc65826 authored by Daniel Watkins's avatar Daniel Watkins

Add gobble count to albums on artist page.

parent b4eacd77
......@@ -39,7 +39,7 @@ class Album {
* @param string name The name of the album to load
* @param string artist The name of the artist who recorded this album
*/
function __construct($name, $artist) {
function __construct($name, $artist, $scrobbles) {
global $mdb2;
$res = $mdb2->query('SELECT name, artist_name, mbid, releasedate FROM Album WHERE '
. 'name = ' . $mdb2->quote($name, 'text') . ' AND '
......@@ -52,6 +52,7 @@ class Album {
$this->mbid = $row['mbid'];
$this->artist_name = $row['artist_name'];
$this->releasedate = $row['releasedate'];
$this->c = $scrobbles;
}
}
......
......@@ -72,10 +72,10 @@ class Artist {
*/
function getAlbums() {
global $mdb2;
$res = $mdb2->query("SELECT name FROM Album WHERE artist_name = "
. $mdb2->quote($this->name, "text"));
$res = $mdb2->query("SELECT COUNT(*) as scrobbles,Track.album FROM Scrobbles JOIN Track ON Scrobbles.track = Track.name WHERE Track.artist = "
. $mdb2->quote($this->name, "text") . " AND Track.artist = Scrobbles.artist AND Track.album IS NOT NULL GROUP BY Track.album");
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$albums[] = new Album($row["name"], $this->name);
$albums[] = new Album($row["album"], $this->name, $row['scrobbles']);
}
return $albums;
......
......@@ -100,7 +100,7 @@ ul.listcloud li dd { margin: 0; padding: 0; }
ul.listcloud li dt a { color: #630000; text-decoration: none; }
ul.listcloud li dt a:hover { text-decoration: underline; }
ul#topartists.listcloud dd { font-size: 80%; line-height: 1.2em; }
ul#topartists.listcloud dd, ul#albums.listcloud dd { font-size: 80%; line-height: 1.2em; }
ul#nowplaying.listcloud li { float: left; margin-right: 10px; margin-bottom: 10px; list-style-type: none; padding: 10px; border: 1px solid #000; background-color: #eee; -moz-border-radius: 5px; height: 4.4em; }
......
......@@ -13,6 +13,7 @@
<dt><a href="album.php?artist={$name|urlencode}&album={$albums[i]->name|urlencode}">
{$albums[i]->name}</a></dt>
<dd>{$albums[i]->releasedate}</dd>
<dd>{$albums[i]->c} gobbles</dd>
</dl>
</li>
{/section}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment