1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 12:30:00 +00:00

Fix Ratings with 0 stars are counted as None

This commit is contained in:
Ozzie Isaacs 2022-07-16 19:09:19 +02:00
parent 61a0c72f8e
commit c2545315e1

View File

@ -598,14 +598,16 @@ def render_series_books(page, book_id, order):
def render_ratings_books(page, book_id, order): def render_ratings_books(page, book_id, order):
if book_id == '-1': if book_id == '-1':
db_filter = coalesce(db.Ratings.rating, 0) < 1
entries, random, pagination = calibre_db.fill_indexpage(page, 0, entries, random, pagination = calibre_db.fill_indexpage(page, 0,
db.Books, db.Books,
db.Books.ratings == None, db_filter,
[order[0][0]], [order[0][0]],
True, config.config_read_column, True, config.config_read_column,
db.books_series_link, db.books_series_link,
db.Books.id == db.books_series_link.c.book, db.Books.id == db.books_series_link.c.book,
db.Series) db.Series,
db.books_ratings_link, db.Ratings)
title = _(u"Rating: None") title = _(u"Rating: None")
rating = -1 rating = -1
else: else:
@ -1018,10 +1020,11 @@ def ratings_list():
entries = calibre_db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'), entries = calibre_db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'),
(db.Ratings.rating / 2).label('name')) \ (db.Ratings.rating / 2).label('name')) \
.join(db.books_ratings_link).join(db.Books).filter(calibre_db.common_filters()) \ .join(db.books_ratings_link).join(db.Books).filter(calibre_db.common_filters()) \
.filter(db.Ratings.rating > 0) \
.group_by(text('books_ratings_link.rating')).order_by(order).all() .group_by(text('books_ratings_link.rating')).order_by(order).all()
no_rating_count = (calibre_db.session.query(db.Books) no_rating_count = (calibre_db.session.query(db.Books)
.outerjoin(db.books_ratings_link).outerjoin(db.Ratings) .outerjoin(db.books_ratings_link).outerjoin(db.Ratings)
.filter(db.Ratings.rating == None) .filter(or_(db.Ratings.rating == None, db.Ratings.rating == 0))
.filter(calibre_db.common_filters()) .filter(calibre_db.common_filters())
.count()) .count())
entries.append([db.Category(_("None"), "-1", -1), no_rating_count]) entries.append([db.Category(_("None"), "-1", -1), no_rating_count])