[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1655] try out a hidden week list
From: |
Clint Adams |
Subject: |
[Librefm-commits] [1655] try out a hidden week list |
Date: |
Sat, 16 May 2009 15:02:46 +0000 |
Revision: 1655
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1655
Author: clint
Date: 2009-05-16 15:02:46 +0000 (Sat, 16 May 2009)
Log Message:
-----------
try out a hidden week list
Modified Paths:
--------------
trunk/nixtape/data/User.php
trunk/nixtape/user-stats.php
Modified: trunk/nixtape/data/User.php
===================================================================
--- trunk/nixtape/data/User.php 2009-05-16 14:27:52 UTC (rev 1654)
+++ trunk/nixtape/data/User.php 2009-05-16 15:02:46 UTC (rev 1655)
@@ -224,10 +224,14 @@
*
* @return user's top 20 tracks
*/
- function getTopTracks($number=20) {
+ function getTopTracks($number=20, $since=null) {
global $adodb;
- $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);
+ 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);
+ } 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);
+ }
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$data = $adodb->CacheGetAll(7200,$query);
if (!$data) {
@@ -236,23 +240,23 @@
$maxcount = 0;
- foreach($data as &$i) {
- $row = sanitize($i);
- $row['artisturl'] = Server::getArtistURL($row['artist']);
- $row['trackurl'] =
Server::getTrackURL($row['artist'],$row['album'],$row['track']);
- if ((int)$row['c'] > $maxcount) {
- $maxcount = (int)$row['c'];
- }
- $result[] = $row;
- }
+ foreach($data as &$i) {
+ $row = sanitize($i);
+ $row['artisturl'] =
Server::getArtistURL($row['artist']);
+ $row['trackurl'] =
Server::getTrackURL($row['artist'],$row['album'],$row['track']);
+ if ((int)$row['c'] > $maxcount) {
+ $maxcount = (int)$row['c'];
+ }
+ $result[] = $row;
+ }
if ($maxcount > 0) {
foreach($result as &$row) {
- $row['width']=(int)(100 * ($row['c']/$maxcount));
+ $row['width']=(int)(100 *
($row['c']/$maxcount));
}
}
- return $result;
+ return $result;
}
Modified: trunk/nixtape/user-stats.php
===================================================================
--- trunk/nixtape/user-stats.php 2009-05-16 14:27:52 UTC (rev 1654)
+++ trunk/nixtape/user-stats.php 2009-05-16 15:02:46 UTC (rev 1655)
@@ -52,7 +52,11 @@
$smarty->assign('user_daystats',$aUserDayStat);
} catch (exception $e) {}
- $smarty->assign('toptracks', $user->getTopTracks(40));
+ if(isset($_GET['week'])) {
+ $smarty->assign('toptracks', $user->getTopTracks(40), time() -
604800);
+ } else {
+ $smarty->assign('toptracks', $user->getTopTracks(40));
+ }
$smarty->assign('me', $user);
$smarty->assign('geo', Server::getLocationDetails($user->location_uri));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1655] try out a hidden week list,
Clint Adams <=