ampache / ampache

A web based audio/video streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device.
http://ampache.org
GNU Affero General Public License v3.0
3.48k stars 587 forks source link

[Feature Request] Make homepage more "alive" #3487

Open fufroma opened 1 year ago

fufroma commented 1 year ago

Hi,

Front page with highlight doesn't move a lot, the new songs/album can't compete with "old but gold" song which already have a lot of "like".

We can add an option to allow user to highlight based only on the like of the last X month instead of all time like.

I made a patch, it work, but I didn't get how to add an option cleanly in the update process, I had to insert the option manually in the database. So I can't push it upstream with a PR.

On our Ampache instance, highlight are now changing a lot, artist and users are quite happy :)

diff --git a/src/Repository/Model/Userflag.php b/src/Repository/Model/Userflag.php
index d176e5d76..491dd01ea 100644
--- a/src/Repository/Model/Userflag.php
+++ b/src/Repository/Model/Userflag.php
@@ -298,6 +298,7 @@ class Userflag extends database_object
     {
         $user_id           = (int)($user_id);
         $allow_group_disks = AmpConfig::get('album_group') && $type == 'album';
+       $how_many_month    = AmpConfig::get('highlight_many_month', 0);
         $sql               = ($allow_group_disks)
             ? "SELECT MIN(`user_flag`.`object_id`) AS `id`, COUNT(DISTINCT(`user_flag`.`user`)) AS `count`, 'album' AS `type`, MAX(`user_flag`.`user`) AS `user`, MAX(`user_flag`.`date`) AS `date` FROM `user_fla
g` LEFT JOIN `album` ON `user_flag`.`object_id` = `album`.`id`"
             : "SELECT DISTINCT(`user_flag`.`object_id`) AS `id`, COUNT(DISTINCT(`user_flag`.`user`)) AS `count`, `user_flag`.`object_type` AS `type`, MAX(`user_flag`.`user`) AS `user`, MAX(`user_flag`.`date`) A
S `date` FROM `user_flag`";
@@ -310,6 +311,9 @@ class Userflag extends database_object
         if (AmpConfig::get('catalog_filter') && $user_id > 0) {
             $sql .= " AND" . Catalog::get_user_filter("user_flag_$type", $user_id);
         }
+       if ($how_many_month > 0) {
+            $sql.=" AND date > unix_timestamp( DATE_SUB(curdate(), INTERVAL ".intval($how_many_month)." MONTH)) ";
+       }
         $sql .= ($allow_group_disks)
             ? " GROUP BY `album`.`prefix`, `album`.`name`, `album`.`album_artist`, `album`.`release_type`, `album`.`release_status`, `album`.`mbid`, `album`.`year`, `album`.`original_year`, `album`.`mbid_group`
 ORDER BY `count` DESC, `date` DESC "
             : " GROUP BY `user_flag`.`object_id`, `type` ORDER BY `count` DESC, `date` DESC ";

diff --git a/src/Repository/Model/Preference.php b/src/Repository/Model/Preference.php
index 9875679d7..68862206f 100644
--- a/src/Repository/Model/Preference.php
+++ b/src/Repository/Model/Preference.php
@@ -90,6 +90,7 @@ class Preference extends database_object
         'geolocation',
         'hide_genres',
         'hide_single_artist',
+       'highlight_many_month',
         'home_moment_albums',
         'home_moment_videos',
         'home_now_playing',
@@ -705,7 +712,9 @@ class Preference extends database_object
             "(170, 'api_hidden_playlists', '', 'Hide playlists in Subsonic and API clients that start with this string', 25, 'string', 'options', null), " .
             "(171, 'api_hide_dupe_searches', '0', 'Hide smartlists that match playlist names in Subsonic and API clients', 25, 'boolean', 'options', NULL), " .
             "(172, 'show_album_artist', '1', 'Show \'Album Artists\' link in the main sidebar', 25, 'boolean', 'interface', 'theme'), " .
-            "(173, 'show_artist', '0', 'Show \'Artists\' link in the main sidebar', 25, 'boolean', 'interface', 'theme');";
+            "(173, 'show_artist', '0', 'Show \'Artists\' link in the main sidebar', 25, 'boolean', 'interface', 'theme'),".
+            "(176, 'highlight_many_month', '0', 'Highlight based on the last X month votes. Set 0 for no time limit.', 75, 'integer', 'interface', 'home');";
         Dba::write($sql);
     } // set_defaults

@@ -890,7 +899,8 @@ class Preference extends database_object
             'api_hidden_playlists' => T_('Hide playlists in Subsonic and API clients that start with this string'),
             'api_hide_dupe_searches' => T_('Hide smartlists that match playlist names in Subsonic and API clients'),
             'show_album_artist' => T_("Show 'Album Artists' link in the main sidebar"),
-            'show_artist' => T_("Show 'Artists' link in the main sidebar")
+            'show_artist' => T_("Show 'Artists' link in the main sidebar"),
+            'highlight_many_month' => T_("Hilight based on the last X month votes. Set 0 for no time limit")
         );
lachlan-00 commented 1 year ago

would that data match one of the browses for mashup pages? mashup.php?action=artist

shangril commented 1 year ago

Hi @lachlan-00 ; Here another Dogmazic volunteer, mainly I assist Fufroma these days with our Ampache install for testing, feedbacks, and general Dogmazic music archive background. To reply as shortly as possible,

If I get you correctly, you wonder if such a move wouldn't make some Mashup pages and the homepage look quite the same.

For our own server this is not the case, mainly because the homepage presents Songs according to their flags, while Artist and Album mashups, artists and album in the "trending" and "popular" tops, and as far as I can guess, maybe plays are part of the algorithm mixtures that determines these tops, and "stars" quite surely

The global appearance of Homepage versus Mashups, with a "two month" patch added to Homepage at our server, shows definitively different things.

Thanx for reading