advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
6.36k stars 448 forks source link

[Enhancement]: Sorting by duration when series collapsed uses first item duration instead of sum of all series duration #3432

Open mattheys opened 2 weeks ago

mattheys commented 2 weeks ago

What happened?

When you collapse the series in Library view and then sort by duration, the duration of the first item in the series seems to be chosen for the sorting. This should probably be a summation of the series duration as it makes the series look like it's the incorrect length.

What did you expect to happen?

The series with that longest combined runtime to be the top of the list.

Steps to reproduce the issue

  1. Go to Library (One that contains multiple books in a series)
  2. Collapse Series
  3. Sort by duration

Audiobookshelf version

2.13.4

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Linux

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Chrome

Logs

No response

Additional Notes

Same can be said for the Size sorting as well.

mikiher commented 1 week ago

@advplyr, do you consider this a bug or a feature?

I think it's a feature, not a bug. Collapse Series just represents all books of a series as one book entry, and should not affect the sorting of the library. The library view is still about books, not about series, and sorting as requested would not be an apple-to-apple comparison.

On the other hand, @mattheys may have a point.

advplyr commented 1 week ago

Using the total duration of the collapsed series is a feature request. However, what can be considered a bug is that currently it sorts the collapsed series using the first book, but doesn't show the duration.

image

Before switching to sqlite collapsed series were always put at the bottom for every sort except title. The series name is used for title sort. Now it is using the first book, but not showing the sort value which could be considered a bug.

There has been a lot of discussion about how to handle collapse series. Before switching to sqlite it was much easier to work with but now that we have to write queries that can be paginated with filter/sort it has become very difficult with the current data models. I believe there is an open feature request for merging the authors for collapsed series and there are a few other threads about sorting collapsed series.

The library view is still about books, not about series, and sorting as requested would not be an apple-to-apple comparison.

This has been my primary argument against treating collapsed series as essentially a merged book. I think there is also a good argument to do it.

If we choose to do this we have to think of a new way to query for the data. I remember coming up with a possible solution in Discord, I'll have to try to find that old conversation.

advplyr commented 1 week ago

I couldn't find the old discussion but I don't think it is worth pursuing this until we are fully off of the old library item model. It will be easier to optimize the queries when we don't have to make every query pulling the data needed for the old library item model.