summaryrefslogtreecommitdiffstats
path: root/lib/class/stats.class.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-01-25 21:08:24 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2013-01-25 21:45:47 -0500
commit1069d54c85149ff1cb51563d6a1fc471695f8b47 (patch)
treee5c22762ef4d6c90dcdb3646a04de26e21ad071c /lib/class/stats.class.php
parentcad1380737f7ffcfa82d46ab3066823435a48a5d (diff)
downloadampache-1069d54c85149ff1cb51563d6a1fc471695f8b47.tar.gz
ampache-1069d54c85149ff1cb51563d6a1fc471695f8b47.tar.bz2
ampache-1069d54c85149ff1cb51563d6a1fc471695f8b47.zip
Move clean functions into their respective classes
Uniformly name them gc()
Diffstat (limited to 'lib/class/stats.class.php')
-rw-r--r--lib/class/stats.class.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php
index e92ed994..4ff676e9 100644
--- a/lib/class/stats.class.php
+++ b/lib/class/stats.class.php
@@ -55,7 +55,18 @@ class Stats {
*/
public static function clear() {
Dba::write('TRUNCATE `object_count`');
- Dba::write('UPDATE `song` SET `played` = 0';
+ Dba::write('UPDATE `song` SET `played` = 0');
+ }
+
+ /**
+ * gc
+ *
+ * This removes stats for things that no longer exist.
+ */
+ public static function gc() {
+ foreach(array('song', 'album', 'artist', 'live_stream', 'video') as $object_type) {
+ Dba::write("DELETE FROM `object_count` USING `object_count` LEFT JOIN `$object_type` ON `$object_type`.`id` = `object_count`.`object_id` WHERE `object_type` = '$object_type' AND `$object_type`.`id` IS NULL");
+ }
}
/**