Sonerezh / sonerezh

A self-hosted, web-based application to stream your music, everywhere.
https://www.sonerezh.bzh
GNU Affero General Public License v3.0
768 stars 122 forks source link

display randomly-selected albums on "Albums" page #298

Closed davebiffuk closed 5 years ago

davebiffuk commented 7 years ago

This is a copy of the "Random albums" feature in Subsonic. A row of randomly-selected albums is displayed on the "Albums" page, after "Recently added" and before "All albums".

The MySQL "order by rand()" is reportedly inefficient, but it takes ~0.1s to select from ~700 albums/~7000 songs on a small ARM-based system which seems acceptable.

I included the (small!) translations but I don't know if I did it right.

This change doesn't handle a SQLite backend, only MySQL.

gs11 commented 7 years ago

Just checked out this to try but I can't see the random albums row in the albums view. screen shot 2017-05-20 at 19 26 42

davebiffuk commented 7 years ago

Did you restart the web server after making the change? I had to restart Apache to make this show up (and when I made other changes, e.g. https://github.com/Sonerezh/sonerezh/issues/170#issuecomment-204693051 )

Are there any messages in the web server logs?

I'm sorry I don't have any other suggestions. I can let you have an account on my server if you want to see it working.

gs11 commented 7 years ago

Not sure what I did wrong the first time but looks & works fine for me now. I think it'd be a good idea if features were database independent, can you add the same functionality for SQLite & PostgreSQL databases?

davebiffuk commented 7 years ago

Thanks for the feedback, I think that's a good idea and I will have a go.

MightyCreak commented 7 years ago

Is it optional? Because personally I would go the other way and remove the Recently Added line.

I know what I added, it takes a precious vertical space. As for the random line, it really depends on the way you listen to your music. I often choose my music based on my mood, so I don't really need the random line (and, also, the vertical space argument)

gs11 commented 7 years ago

Could this be optional on the settings page? A checkbox for recently added and another one for random?

MightyCreak commented 7 years ago

That would be very nice. It could even be per user.

davebiffuk commented 7 years ago

I've updated my branch to add checkboxes for "random" and "recently added" on the settings page. Thanks for the suggestion!

NB. as I wrote in the commit message:

This involves a change to the database schema. In theory,
deleting the contents of sonerezh/app/tmp/cache/models
is sufficient to get that noticed; but in my experience,
setting Configure::write('debug', 2); in
sonerezh/app/Config/core.php (briefly) was necessary.

Still only for MySQL I'm afraid, I will look at other backends next.

davebiffuk commented 7 years ago

I've added (completely untested) support for SQLite and PostgreSQL. Any testers please?

gs11 commented 7 years ago

Looks good but sonerezh_pgsql.php is missing the two new columns. Once they were added it seems to be working just fine with sqlite.

MightyCreak commented 5 years ago

This PR should fix #299