librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1877] use userid instead of username for scrobbles ta


From: Clint Adams
Subject: [Librefm-commits] [1877] use userid instead of username for scrobbles table
Date: Fri, 29 May 2009 00:40:28 +0000

Revision: 1877
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1877
Author:   clint
Date:     2009-05-29 00:40:28 +0000 (Fri, 29 May 2009)
Log Message:
-----------
use userid instead of username for scrobbles table

Modified Paths:
--------------
    trunk/nixtape/data/Artist.php
    trunk/nixtape/data/Group.php
    trunk/nixtape/data/Server.php
    trunk/nixtape/data/TagCloud.php
    trunk/nixtape/data/Track.php
    trunk/nixtape/data/User.php
    trunk/nixtape/delete-profile.php

Modified: trunk/nixtape/data/Artist.php
===================================================================
--- trunk/nixtape/data/Artist.php       2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/data/Artist.php       2009-05-29 00:40:28 UTC (rev 1877)
@@ -113,7 +113,7 @@
                global $adodb;
                $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
                $res = $adodb->CacheGetAll(600,
-                       'SELECT track, COUNT(track) AS freq, COUNT(DISTINCT 
username) AS listeners FROM Scrobbles WHERE'
+                       'SELECT track, COUNT(track) AS freq, COUNT(DISTINCT 
userid) AS listeners FROM Scrobbles WHERE'
                        . ' artist = ' . $adodb->qstr($this->name)
                        . ' GROUP BY track ORDER BY freq DESC LIMIT ' . 
(int)($number));
                foreach($res as &$row) {

Modified: trunk/nixtape/data/Group.php
===================================================================
--- trunk/nixtape/data/Group.php        2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/data/Group.php        2009-05-29 00:40:28 UTC (rev 1877)
@@ -378,7 +378,7 @@
 
        function tagCloudData () {
                return TagCloud::generateTagCloud(
-                               TagCloud::scrobblesTable('group').' s LEFT JOIN 
Users u ON s.username=u.username LEFT JOIN Group_Members gm ON 
u.uniqueid=gm.member LEFT JOIN Groups g ON gm.grp=g.id',
+                               TagCloud::scrobblesTable('group').' s LEFT JOIN 
Users u ON s.userid=u.uniqueid LEFT JOIN Group_Members gm ON 
u.uniqueid=gm.member LEFT JOIN Groups g ON gm.grp=g.id',
                                'artist',
                                40,
                                $this->name,

Modified: trunk/nixtape/data/Server.php
===================================================================
--- trunk/nixtape/data/Server.php       2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/data/Server.php       2009-05-29 00:40:28 UTC (rev 1877)
@@ -52,7 +52,7 @@
                if($username) {
                        $res = $adodb->CacheGetAll(60,
                                'SELECT
-                                       s.username,
+                                       s.userid,
                                        s.artist,
                                        s.track,
                                        s.album,
@@ -73,14 +73,14 @@
                                        ON s.stid = st.id
                                LEFT JOIN Track t
                                        ON st.track = t.id
-                               WHERE lower(s.username) = ' . 
$adodb->qstr(strtolower($username)) . '
+                               WHERE s.userid = ' . 
username_to_uniqueid($username) . '
                                ORDER BY
                                        s.time DESC
                                LIMIT ' . (int)($number));
                } else {
                        $res = $adodb->CacheGetAll(60,
                                'SELECT
-                                       s.username,
+                                       s.userid,
                                        s.artist,
                                        s.track,
                                        s.album,
@@ -113,7 +113,7 @@
                foreach($res as &$i) {
                        $row = sanitize($i);
 
-                       $row['userurl'] = Server::getUserURL($row['username']);
+                       $row['userurl'] = 
Server::getUserURL(uniqueid_to_username($row['userid']));
                        if ($row['album']) {
                                $row['albumurl'] = 
Server::getAlbumURL($row['artist'], $row['album']);
                        }
@@ -123,10 +123,10 @@
                        $row['timehuman'] = human_timestamp($row['time']);
                        $row['timeiso']   = date('c', (int)$row['time']);
 
-                       $row['id']        = 
identifierScrobbleEvent($row['username'], $row['artist'], $row['track'], 
$row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], 
$row['album_mbid']);
-                       $row['id_artist'] = identifierArtist($row['username'], 
$row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], 
$row['artist_mbid'], $row['album_mbid']);
-                       $row['id_track']  = identifierTrack($row['username'], 
$row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], 
$row['artist_mbid'], $row['album_mbid']);
-                       $row['id_album']  = identifierAlbum($row['username'], 
$row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], 
$row['artist_mbid'], $row['album_mbid']);
+                       $row['id']        = 
identifierScrobbleEvent(uniqueid_to_username($row['userid']), $row['artist'], 
$row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], 
$row['album_mbid']);
+                       $row['id_artist'] = 
identifierArtist(uniqueid_to_username($row['userid']), $row['artist'], 
$row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], 
$row['album_mbid']);
+                       $row['id_track']  = 
identifierTrack(uniqueid_to_username($row['userid']), $row['artist'], 
$row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], 
$row['album_mbid']);
+                       $row['id_album']  = 
identifierAlbum(uniqueid_to_username($row['userid']), $row['artist'], 
$row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], 
$row['album_mbid']);
 
                        if (!$row['album_image']) {
                                $row['album_image'] = false;

Modified: trunk/nixtape/data/TagCloud.php
===================================================================
--- trunk/nixtape/data/TagCloud.php     2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/data/TagCloud.php     2009-05-29 00:40:28 UTC (rev 1877)
@@ -47,7 +47,7 @@
                } elseif ($field == 'track') {
                        $query .= (!is_null($constraint)) ? ' artist = ' . 
$adodb->qstr($constraint) : null;
                } else {
-                       $query .= (!is_null($constraint)) ? ' username = ' . 
$adodb->qstr($constraint) : null;
+                       $query .= (!is_null($constraint)) ? ' userid = ' . 
$adodb->qstr($constraint) : null;
                }
                $query .= ' GROUP BY ' . $field . ' ORDER BY count DESC LIMIT ' 
. $limit;
                $adodb->SetFetchMode(ADODB_FETCH_ASSOC);

Modified: trunk/nixtape/data/Track.php
===================================================================
--- trunk/nixtape/data/Track.php        2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/data/Track.php        2009-05-29 00:40:28 UTC (rev 1877)
@@ -122,7 +122,7 @@
                global $adodb;
 
                $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
-               $row = $adodb->CacheGetRow(300, 'SELECT COUNT(track) AS freq, 
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE'
+               $row = $adodb->CacheGetRow(300, 'SELECT COUNT(track) AS freq, 
COUNT(DISTINCT userid) AS listeners FROM Scrobbles WHERE'
                        . ' artist = ' . $adodb->qstr($this->artist_name)
                        . ' AND track = ' . $adodb->qstr($this->name)
                        . ' GROUP BY track ORDER BY freq DESC');

Modified: trunk/nixtape/data/User.php
===================================================================
--- trunk/nixtape/data/User.php 2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/data/User.php 2009-05-29 00:40:28 UTC (rev 1877)
@@ -234,9 +234,9 @@
                global $adodb;
 
                if ($since) {
-                       $query = 'SELECT COUNT(track) as c, artist, album, 
track FROM Scrobbles WHERE username = '.$adodb->qstr($this->name).' AND time > 
'.(int)($since).' GROUP BY artist,album,track ORDER BY c DESC LIMIT ' . 
($number);
+                       $query = 'SELECT COUNT(track) as c, artist, album, 
track FROM Scrobbles WHERE userid = '.($this->uniqueid).' AND time > 
'.(int)($since).' GROUP BY artist,album,track ORDER BY c DESC LIMIT ' . 
($number);
                } else {
-                       $query = 'SELECT COUNT(track) as c, artist, album, 
track FROM Scrobbles WHERE username = '.$adodb->qstr($this->name).' GROUP BY 
artist,album,track ORDER BY c DESC LIMIT ' . ($number);
+                       $query = 'SELECT COUNT(track) as c, artist, album, 
track FROM Scrobbles WHERE userid = '.($this->uniqueid).' GROUP BY 
artist,album,track ORDER BY c DESC LIMIT ' . ($number);
                }
                $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
                $data = $adodb->CacheGetAll(7200,$query);
@@ -269,9 +269,9 @@
                global $adodb;
 
                if ($since) {
-                       $query = 'SELECT COUNT(*) FROM Scrobbles WHERE username 
= '.$adodb->qstr($this->name).' AND time > '.(int)($since);
+                       $query = 'SELECT COUNT(*) FROM Scrobbles WHERE userid = 
'.($this->uniqueid).' AND time > '.(int)($since);
                } else {
-                       $query = 'SELECT COUNT(*) FROM Scrobbles WHERE username 
= '.$adodb->qstr($this->name);
+                       $query = 'SELECT COUNT(*) FROM Scrobbles WHERE userid = 
'.($this->uniqueid);
                }
                try {
                        $tracks = $adodb->CacheGetOne(200, $query);

Modified: trunk/nixtape/delete-profile.php
===================================================================
--- trunk/nixtape/delete-profile.php    2009-05-29 00:35:47 UTC (rev 1876)
+++ trunk/nixtape/delete-profile.php    2009-05-29 00:40:28 UTC (rev 1877)
@@ -22,6 +22,7 @@
 require_once ('templating.php');
 require_once ('data/User.php');
 require_once ('utils/random_code_generator.php');
+require_once($install_path . '/../turtle/temp-utils.php'); // this is 
extremely dodgy and shameful
 
 if ($logged_in == false) {
        $smarty->assign('error', 'Error!');
@@ -52,7 +53,7 @@
                $adodb->Execute('DELETE FROM Group_Members WHERE member = ' . 
(int)($this_user->uniqueid));
                $adodb->Execute('DELETE FROM Radio_Sessions WHERE username = ' 
. $adodb->qstr($username));
                $adodb->Execute('DELETE FROM Recovery_Request WHERE username = 
' . $adodb->qstr($username));
-               $adodb->Execute('DELETE FROM Scrobbles WHERE username = ' . 
$adodb->qstr($username));
+               $adodb->Execute('DELETE FROM Scrobbles WHERE userid = ' . 
username_to_uniqueid($username));
                $adodb->Execute('DELETE FROM User_Relationship_Flags WHERE uid1 
= ' . (int)($this_user->uniqueid));
                $adodb->Execute('DELETE FROM User_Relationship_Flags WHERE uid2 
= ' . (int)($this_user->uniqueid));
                $adodb->Execute('DELETE FROM User_Relationships WHERE uid1 = ' 
. (int)($this_user->uniqueid));





reply via email to

[Prev in Thread] Current Thread [Next in Thread]