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 }