summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-10 22:10:33 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-10 22:10:33 +0000
commitc3e9518ab49817e05033736c6cca7605c0761cab (patch)
treeb16f9f79e7b4f7eeb1c85e8143eac377f9333cc3 /lib/class
parent67ab0016bfb15415034ace50a63e1c8cbd3f0bd4 (diff)
downloadampache-c3e9518ab49817e05033736c6cca7605c0761cab.tar.gz
ampache-c3e9518ab49817e05033736c6cca7605c0761cab.tar.bz2
ampache-c3e9518ab49817e05033736c6cca7605c0761cab.zip
fixed stats recording mostly
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/stats.class.php20
-rw-r--r--lib/class/user.class.php11
2 files changed, 15 insertions, 16 deletions
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php
index 5eef86d7..6add04c5 100644
--- a/lib/class/stats.class.php
+++ b/lib/class/stats.class.php
@@ -40,7 +40,7 @@ class Stats {
* Constructor
* This doesn't do anything currently
*/
- function Stats() {
+ public function __construct() {
return true;
@@ -51,16 +51,16 @@ class Stats {
* This inserts a new record for the specified object
* with the specified information, amazing!
*/
- function insert($type,$oid,$user) {
+ public static function insert($type,$oid,$user) {
- $type = $this->validate_type($type);
- $oid = sql_escape($oid);
- $user = sql_escape($user);
+ $type = self::validate_type($type);
+ $oid = Dba::escape($oid);
+ $user = Dba::escape($user);
$date = time();
- $sql = "INSERT INTO object_count (`object_type`,`object_id`,`date`,`user`) " .
+ $sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`date`,`user`) " .
" VALUES ('$type','$oid','$date','$user')";
- $db_results = mysql_query($sql,dbh());
+ $db_results = Dba::query($sql);
if (!$db_results) {
debug_event('statistics','Unabled to insert statistics:' . $sql,'3');
@@ -73,7 +73,7 @@ class Stats {
* This returns the top X for type Y from the
* last conf('stats_threshold') days
*/
- function get_top($count,$type,$threshold = '') {
+ public static function get_top($count,$type,$threshold = '') {
/* If they don't pass one, then use the preference */
if (!$threshold) {
@@ -81,7 +81,7 @@ class Stats {
}
$count = intval($count);
- $type = $this->validate_type($type);
+ $type = self::validate_type($type);
$date = time() - (86400*$threshold);
/* Select Top objects counting by # of rows */
@@ -120,7 +120,7 @@ class Stats {
}
/* Select Objects based on user */
- //FIXME:: Requires table can, look at improving
+ //FIXME:: Requires table scan, look at improving
$sql = "SELECT object_id,COUNT(id) AS `count` FROM object_count" .
" WHERE object_type='$type' AND date >= '$date' AND user = '$user'" .
" GROUP BY object_id ORDER BY `count` DESC LIMIT $count";
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 4019ba98..876b4a36 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -511,18 +511,17 @@ class User {
* update_user_stats
* updates the playcount mojo for this specific user
*/
- function update_stats($song_id) {
+ public function update_stats($song_id) {
$song_info = new Song($song_id);
$user = $this->id;
if (!$song_info->file) { return false; }
- $stats = new Stats();
- $stats->insert('song',$song_id,$user);
- $stats->insert('album',$song_info->album,$user);
- $stats->insert('artist',$song_info->artist,$user);
- $stats->insert('genre',$song_info->genre,$user);
+ Stats::insert('song',$song_id,$user);
+ Stats::insert('album',$song_info->album,$user);
+ Stats::insert('artist',$song_info->artist,$user);
+ Stats::insert('genre',$song_info->genre,$user);
/**
* Record this play to LastFM