git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 7d8ba094 authored by Jonas Haraldsson's avatar Jonas Haraldsson

Disable forwarding, replace index

Disable scrobble forwarding for now, needs testing.

Replaced Scrobbles(userid) index with Scrobbles(userid, time) index to
prevent db from using only userid index when time index is much faster.
This will also speed up getrecenttracks queries.
parent 89def678
......@@ -379,10 +379,10 @@ if (isset($_POST['install'])) {
}
$adodb->Execute("CREATE INDEX scrobbles_time_idx ON Scrobbles(time)");
$adodb->Execute("CREATE INDEX scrobbles_userid_idx ON Scrobbles(userid)");
$adodb->Execute("CREATE INDEX track_streamable_idx on Track(streamable);");
$adodb->Execute("CREATE INDEX scrobbles_userid_time_idx ON Scrobbles(userid, time)");
$adodb->Execute("CREATE INDEX scrobbles_track_idx on Scrobbles(track)");
$adodb->Execute("CREATE INDEX scrobble_track_name_idx ON Scrobble_Track(name)");
$adodb->Execute("CREATE INDEX track_streamable_idx on Track(streamable);");
$adodb->Execute("CREATE INDEX track_name_idx ON Track(name)");
$adodb->Execute("CREATE INDEX album_name_idx ON Album(name)");
$adodb->Execute("CREATE INDEX artist_name_idx ON Artist(name)");
......
......@@ -161,6 +161,8 @@ class TrackXML {
public static function updateNowPlaying($userid, $artist, $track, $album, $tracknumber, $context, $mbid, $duration, $albumartist, $api_key) {
global $adodb;
$sessionid = getScrobbleSessionID($userid, $api_key);
$t = array(
'artist' => $artist,
'track' => $track,
......@@ -173,9 +175,6 @@ class TrackXML {
$t = prepareTrack($userid, $t, 'nowplaying');
// Get a scrobble session id. TODO check if we got one
$sessionid = getScrobbleSessionID($userid, $api_key);
// Delete last played track
$query = 'DELETE FROM Now_Playing WHERE sessionid = ?';
$params = array($sessionid);
......@@ -185,7 +184,7 @@ class TrackXML {
// Calculate expiry time
if (!$t['duration'] || ($t['duration'] > 5400)) {
// Default expiry time of 5 minutes if $duration is false or above 5400
// Default expiry time of 300 seconds if duration is false or above 5400 seconds
$expires = time() + 300;
} else {
$expires = time() + $t['duration'];
......@@ -234,14 +233,14 @@ class TrackXML {
public static function scrobble($userid, $artist, $track, $timestamp, $album, $context, $streamid, $chosenbyuser, $tracknumber, $mbid, $albumartist, $duration, $api_key) {
global $adodb;
// Get a scrobble session id. TODO check if we got one
$sessionid = getScrobbleSessionID($userid, $api_key);
$accepted_count = 0;
$ignored_count = 0;
$tracks_array = array();
// Convert input to track item arrays and add them to tracks_array
// Convert input to track arrays and add them to tracks_array
if (is_array($artist)) {
for ($i = 0; $i < count($artist); $i++) {
$tracks_array[$i] = array(
......@@ -309,8 +308,6 @@ class TrackXML {
$adodb->Execute($query, $params);
} catch (Exception $e) {
// Roll back database entries, log error and respond with error message
// TODO what happens to User_Stats(scrobble_count) db field when we roll back scrobbles,
// do we need to move sql function into php?
$adodb->FailTrans();
$adodb->CompleteTrans();
reportError($e->getMessage(), $e->getTraceAsString());
......@@ -330,8 +327,8 @@ class TrackXML {
$t = $tracks_array[$i];
if ($t['ignoredcode'] === 0) {
/* Forward scrobbles, we are forwarding unmodified input submitted by user,
* but only the scrobbles that passed our filters. */
// TODO : Test forwarding!
* but only the scrobbles that passed our ignore filters, see prepareTrack(). */
/* TODO : Test forwarding, disabled for now
forwardScrobble($userid,
$t['artist_old'],
$t['album_old'],
......@@ -341,6 +338,7 @@ class TrackXML {
null,
null,
$t['duration_old']);
*/
}
}
}
......
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