summaryrefslogtreecommitdiffstats
path: root/lib/class/rating.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class/rating.class.php')
-rw-r--r--lib/class/rating.class.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index 616baad6..0943de2f 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -49,6 +49,17 @@ class Rating extends database_object {
} // Constructor
/**
+ * gc
+ *
+ * Remove ratings for items that no longer exist.
+ */
+ public static function gc() {
+ foreach(array('song', 'album', 'artist', 'video') as $object_type) {
+ Dba::write("DELETE FROM `rating` USING `rating` LEFT JOIN `$object_type` ON `$object_type`.`id` = `rating`.`object_type` WHERE `object_type` = '$object_type` AND `$object_type`.`id` IS NULL");
+ }
+ }
+
+ /**
* build_cache
* This attempts to get everything we'll need for this page load in a
* single query, saving on connection overhead