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

Commit 0c751234 authored by clint's avatar clint

rename track members album and artist to album_name and artist_name so we can get rid of them later

parent f6762e03
......@@ -142,8 +142,8 @@ if (isset($_POST['install'])) {
$adodb->Execute("CREATE TABLE Track(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
artist VARCHAR(255) REFERENCES Artist(name),
album VARCHAR(255),
artist_name VARCHAR(255) REFERENCES Artist(name),
album_name VARCHAR(255),
mbid VARCHAR(36),
duration INTEGER,
streamable INTEGER DEFAULT 0,
......@@ -156,8 +156,8 @@ if (isset($_POST['install'])) {
$adodb->Execute("CREATE TABLE Track(
id INTEGER NOT NULL DEFAULT nextval('track_id_seq'::regclass) PRIMARY KEY,
name VARCHAR(255),
artist VARCHAR(255) REFERENCES Artist(name),
album VARCHAR(255),
artist_name VARCHAR(255) REFERENCES Artist(name),
album_name VARCHAR(255),
mbid VARCHAR(36),
duration INTEGER,
streamable INTEGER DEFAULT 0,
......@@ -297,7 +297,7 @@ if (isset($_POST['install'])) {
// $adodb->Execute("CREATE INDEX album_artistname_idx ON Album(artist_name)");
// $adodb->Execute("CREATE INDEX scrobbles_artist_idx ON Scrobbles(artist)");
// $adodb->Execute("CREATE INDEX scrobbles_time_idx ON Scrobbles(time)");
// $adodb->Execute("CREATE INDEX track_artist_idx ON Track(lower(artist))");
// $adodb->Execute("CREATE INDEX track_artist_idx ON Track(lower(artist_name))");
// $adodb->Execute("CREATE INDEX track_name_idx ON Track(lower(name))");
// $adodb->Execute("CREATE INDEX track_streamable_idx on Track(streamable);");
// $adodb->Execute("CREATE INDEX scrobbles_artist_idx on Scrobbles(lower(artist))");
......
......@@ -104,9 +104,9 @@ function getTrackCreateIfNew($artist, $album, $track, $mbid) {
$artist = NoSpamTracks($artist);
if($album != 'NULL') {
$res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = lower(" . ($track) . ") AND lower(artist) = lower(" . ($artist) . ") AND lower(album) = lower(" . ($album) . ")");
$res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = lower(" . ($track) . ") AND lower(artist_name) = lower(" . ($artist) . ") AND lower(album_name) = lower(" . ($album) . ")");
} else {
$res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = lower(" . ($track) . ") AND lower(artist) = lower(" . ($artist) . ") AND album IS NULL");
$res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = lower(" . ($track) . ") AND lower(artist_name) = lower(" . ($artist) . ") AND album_name IS NULL");
}
if(PEAR::isError($res)) {
die("FAILED trk " . $res->getMessage() . "\n");
......@@ -114,7 +114,7 @@ function getTrackCreateIfNew($artist, $album, $track, $mbid) {
if(!$res->numRows()) {
// Create new track
$res = $mdb2->exec("INSERT INTO Track (name, artist, album, mbid) VALUES ("
$res = $mdb2->exec("INSERT INTO Track (name, artist_name, album_name, mbid) VALUES ("
. ($track) . ", "
. ($artist) . ", "
. ($album) . ", "
......
......@@ -25,7 +25,7 @@ require_once($install_path . '/templating.php');
require_once($install_path . '/data/sanitize.php');
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$recordSet = &$adodb->CacheExecute(7200, 'SELECT t.id, t.artist, t.album, t.name, t.mbid as tmbid, st.mbid as stmbid FROM Scrobble_Track st JOIN Track t ON lower(t.name)=st.name AND lower(t.album)=st.album AND lower(t.artist)=st.artist AND t.mbid<>st.mbid');
$recordSet = &$adodb->CacheExecute(7200, 'SELECT t.id, t.artist_name, t.album_name, t.name, t.mbid as tmbid, st.mbid as stmbid FROM Scrobble_Track st JOIN Track t ON lower(t.name)=st.name AND lower(t.album_name)=st.album AND lower(t.artist_name)=st.artist AND t.mbid<>st.mbid');
$aEntries = array();
$i = 0;
......
......@@ -75,7 +75,7 @@ class Album {
function getPlayCount() {
global $mdb2;
$res = $mdb2->query("SELECT COUNT(*) AS scrobbles FROM Scrobbles JOIN Track ON Scrobbles.track = Track.name WHERE Scrobbles.artist = "
. $mdb2->quote($this->artist_name, 'text') . ' AND Track.album ='
. $mdb2->quote($this->artist_name, 'text') . ' AND Track.album_name ='
. $mdb2->quote($this->name, 'text'));
if(PEAR::isError($res)) {
reportError($res->getMessage(), $res->getUserInfo());
......@@ -95,11 +95,11 @@ class Album {
*/
function getTracks() {
global $mdb2;
$res = $mdb2->query('SELECT name, artist FROM Track WHERE artist = '
. $mdb2->quote($this->artist_name, 'text') . ' AND album = '
$res = $mdb2->query('SELECT name, artist_name FROM Track WHERE artist_name = '
. $mdb2->quote($this->artist_name, 'text') . ' AND album_name = '
. $mdb2->quote($this->name));
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$tracks[] = new Track($row['name'], $row['artist']);
$tracks[] = new Track($row['name'], $row['artist_name']);
}
return $tracks;
......
......@@ -92,7 +92,7 @@ class Artist {
*/
function getTracks() {
global $mdb2;
$res = $mdb2->query("SELECT name FROM Track WHERE artist = "
$res = $mdb2->query("SELECT name FROM Track WHERE artist_name = "
. $mdb2->quote($this->name, "text"));
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$tracks[] = new Track($row["name"], $this->name);
......
......@@ -196,8 +196,8 @@ class Server {
LEFT OUTER JOIN ClientCodes
ON Scrobble_Sessions.client=ClientCodes.code
LEFT OUTER JOIN Track t
ON lower(n.artist) = lower(t.artist)
AND lower(n.album) = lower(t.album)
ON lower(n.artist) = lower(t.artist_name)
AND lower(n.album) = lower(t.album_name)
AND lower(n.track) = lower(t.name)
AND lower(n.mbid) = lower(t.mbid)
WHERE lower(username) = " . $mdb2->quote(strtolower($username), "text") . "
......@@ -220,8 +220,8 @@ class Server {
LEFT OUTER JOIN ClientCodes
ON Scrobble_Sessions.client=ClientCodes.code
LEFT OUTER JOIN Track t
ON lower(n.artist) = lower(t.artist)
AND lower(n.album) = lower(t.album)
ON lower(n.artist) = lower(t.artist_name)
AND lower(n.album) = lower(t.album_name)
AND lower(n.track) = lower(t.name)
AND lower(n.mbid) = lower(t.mbid)
ORDER BY t.streamable DESC, n.expires DESC LIMIT " . $mdb2->quote($number, "integer"));
......
......@@ -48,17 +48,17 @@ class Track {
*/
function __construct($name, $artist) {
global $mdb2;
$res = $mdb2->query("SELECT name, artist, album, duration, streamable, license, downloadurl, streamurl, mbid FROM Track WHERE "
$res = $mdb2->query("SELECT name, artist_name, album_name, duration, streamable, license, downloadurl, streamurl, mbid FROM Track WHERE "
. "name = " . $mdb2->quote($name, "text") . " AND "
. "artist = " . $mdb2->quote($artist, "text"));
. "artist_name = " . $mdb2->quote($artist, "text"));
if(!$res->numRows()) {
$this->name = "No such track: " . $name;
} else {
$row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
$this->name = $row["name"];
$this->mbid = $row["mbid"];
$this->artist_name = $row["artist"];
$this->album_name = $row["album"];
$this->artist_name = $row["artist_name"];
$this->album_name = $row["album_name"];
$this->duration = $row["duration"];
$this->streamable = $row["streamable"];
$this->license = simplify_license($row["license"]);
......
......@@ -44,10 +44,10 @@ $smarty->assign('title', $title);
if(ereg("l(ast|ibre)fm://globaltags/(.*)", $url, $regs)) {
$tag = $regs[2];
$res = $mdb2->query("SELECT Track.name, Track.artist, Track.album FROM Track INNER JOIN Tags ON Track.name=Tags.track AND Track.artist=Tags.artist AND Track.album=Tags.album WHERE streamurl<>'' AND streamable=1 AND lower(tag) = " . $mdb2->quote(mb_strtolower($tag, "UTF-8"), "text"));
$res = $mdb2->query("SELECT Track.name, Track.artist_name, Track.album_name FROM Track INNER JOIN Tags ON Track.name=Tags.track AND Track.artist_name=Tags.artist AND Track.album_name=Tags.album WHERE streamurl<>'' AND streamable=1 AND lower(tag) = " . $mdb2->quote(mb_strtolower($tag, "UTF-8"), "text"));
} elseif(ereg("l(ast|ibre)fm://artist/(.*)/similarartists", $url, $regs)) {
$artist = $regs[2];
$res = $mdb2->query("SELECT name, artist, album FROM Track WHERE streamurl<>'' AND streamable=1 AND lower(artist) = " . $mdb2->quote(mb_strtolower($artist, "UTF-8"), "text"));
$res = $mdb2->query("SELECT name, artist_name, album_name FROM Track WHERE streamurl<>'' AND streamable=1 AND lower(artist_name) = " . $mdb2->quote(mb_strtolower($artist, "UTF-8"), "text"));
} else {
die("FAILED\n"); // this should return a blank dummy playlist instead
}
......@@ -70,9 +70,9 @@ $radiotracks = array();
$res->seek($tr[$i]);
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
$track = new Track($row["name"], $row["artist"]);
$album = new Album($row["album"], $row["artist"]);
$artist = new Artist($row["artist"]);
$track = new Track($row["name"], $row["artist_name"]);
$album = new Album($row["album_name"], $row["artist_name"]);
$artist = new Artist($row["artist_name"]);
if($track->duration == 0) {
$duration = 180000;
......
......@@ -40,7 +40,7 @@ if (!PEAR::isError ($aTagCloud)) {
$smarty->assign('tagcloud', $aTagCloud);
}
$res = $mdb2->query("SELECT * FROM Track WHERE lower(artist) = " . $mdb2->quote(mb_strtolower($track->artist_name, "UTF-8"),"text") . " AND lower(name) = " . $mdb2->quote(mb_strtolower($track->name, "UTF-8"),"text"));
$res = $mdb2->query("SELECT * FROM Track WHERE lower(artist_name) = " . $mdb2->quote(mb_strtolower($track->artist_name, "UTF-8"),"text") . " AND lower(name) = " . $mdb2->quote(mb_strtolower($track->name, "UTF-8"),"text"));
$aOtheralbums = array();
$i = 0;
......
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