Commit 55af9a55 authored by Mike Sheldon's avatar Mike Sheldon

Provide User objects inside the neighbour list

parent e4be8fdf
......@@ -503,7 +503,7 @@ class User {
* Find the neighbours of this user based on the number of loved artists shared between them and other users.
*
* @param int The number of neighbours to return (defaults to 10).
* @return array An array of userids and the number of loved artists shared with this user.
* @return array An array of userids, User objects and the number of loved artists shared with this user.
*/
function getNeighbours($limit=10) {
global $adodb;
......@@ -511,7 +511,11 @@ class User {
return array();
}
$res = $adodb->CacheGetAll(7200, 'SELECT Loved_Tracks.userid, count(Loved_Tracks.userid) AS shared_artists FROM Loved_Tracks INNER JOIN (SELECT DISTINCT(artist) AS artist FROM Loved_Tracks WHERE userid=' . $this->uniqueid . ') AS Loved_Artists ON Loved_Tracks.artist = Loved_Artists.artist WHERE userid != ' . $this->uniqueid . ' GROUP BY Loved_Tracks.userid ORDER BY shared_artists DESC LIMIT ' . $limit);
$res = $adodb->CacheGetAll(7200, 'SELECT Loved_Tracks.userid AS userid, count(Loved_Tracks.userid) AS shared_artists FROM Loved_Tracks INNER JOIN (SELECT DISTINCT(artist) AS artist FROM Loved_Tracks WHERE userid=' . $this->uniqueid . ') AS Loved_Artists ON Loved_Tracks.artist = Loved_Artists.artist WHERE userid != ' . $this->uniqueid . ' GROUP BY Loved_Tracks.userid ORDER BY shared_artists DESC LIMIT ' . $limit);
foreach($res as &$neighbour) {
$neighbour['user'] = User::new_from_uniqueid_number($neighbour['userid']);
}
return $res;
}
......
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