From abf10c09042d5548ea8e5e4a0ef0cf639ce93e2d Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Thu, 17 May 2018 22:16:07 +0500 Subject: [PATCH] Proper pagination. --- pastes/queries.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pastes/queries.go b/pastes/queries.go index 74b1e91..ab91a04 100644 --- a/pastes/queries.go +++ b/pastes/queries.go @@ -66,7 +66,7 @@ func GetPagedPastes(page int) ([]Paste, error) { func GetPastesPages() int { var pastesCount int dbConn := c.Database.GetDatabaseConnection() - err := dbConn.Get(&pastesCount, "SELECT COUNT(id) FROM `pastes`") + err := dbConn.Get(&pastesCount, "SELECT COUNT(id) FROM `pastes` WHERE private != true") if err != nil { return 1 } @@ -74,8 +74,8 @@ func GetPastesPages() int { // Calculate pages. pages := pastesCount / PAGINATION // Check if we have any remainder. Add 1 to pages count if so. - if pastesCount%PAGINATION != 0 { - pages += 1 + if pastesCount%PAGINATION > 0 { + pages++ } return pages