summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/class/stats.class.php8
-rw-r--r--stats.php21
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php
index a687cd69..0c8a69cd 100644
--- a/lib/class/stats.class.php
+++ b/lib/class/stats.class.php
@@ -94,13 +94,17 @@ class Stats {
* This returns the top X for type Y from the
* last conf('stats_threshold') days
*/
- public static function get_top($count,$type,$threshold = '') {
+ public static function get_top($type,$count='',$threshold = '') {
/* If they don't pass one, then use the preference */
if (!$threshold) {
$threshold = Config::get('stats_threshold');
}
+ if (!$count) {
+ $count = Config::get('popular_threshold');
+ }
+
$count = intval($count);
$type = self::validate_type($type);
$date = time() - (86400*$threshold);
@@ -114,7 +118,7 @@ class Stats {
$results = array();
while ($r = Dba::fetch_assoc($db_results)) {
- $results[] = $r;
+ $results[] = new $type($r['object_id']);
}
return $results;
diff --git a/stats.php b/stats.php
index c69ecc8a..b5a9632e 100644
--- a/stats.php
+++ b/stats.php
@@ -50,7 +50,26 @@ switch ($_REQUEST['action']) {
// Global stuff first
$stats = Catalog::get_stats();
require_once Config::get('prefix') . '/templates/show_local_catalog_info.inc.php';
-
+
+ $objects = Stats::get_top('album');
+ $headers = array('f_link'=>_('Most Popular Albums'));
+ show_box_top('','info-box box_popular_albums');
+ require Config::get('prefix') . '/templates/show_objects.inc.php';
+ show_box_bottom();
+
+ $objects = Stats::get_top('artist');
+ $headers = array('f_name_link'=>_('Most Popular Artists'));
+ show_box_top('','info-box box_popular_artists');
+ require Config::get('prefix') . '/templates/show_objects.inc.php';
+ show_box_bottom();
+
+ $objects = Stats::get_top('genre');
+ $headers = array('f_link'=>_('Most Popular Genres'));
+ show_box_top('','info-box box_popular_genres');
+ require Config::get('prefix') . '/templates/show_objects.inc.php';
+ show_box_bottom();
+
+
break;
} // end switch on action