From 1bfb3771740aa29ff3bc4ca0cd8ef84aee45c9d4 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Fri, 7 May 2021 07:51:57 +0000 Subject: [PATCH] Don't count estimate for moderation queue --- lib/database/books.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/database/books.go b/lib/database/books.go index a465cf8..7c1d5ea 100644 --- a/lib/database/books.go +++ b/lib/database/books.go @@ -85,12 +85,16 @@ func (db *pgDB) getBooks(active bool, query string, length int, start int) (book order = strings.Join(rank, "+") + " DESC, upload_date DESC" } - num, err = db.sql.Model(&books). + q := db.sql.Model(&books). Where(searchCondition, searchParams...). OrderExpr(order, rankParams...). Offset(start). - Limit(length). - SelectAndCountEstimate(1000) + Limit(length) + if active { + num, err = q.SelectAndCountEstimate(1000) + } else { + num, err = q.SelectAndCount() + } return books, num, err }