From b643e0520f9f907c1b4142cd70545c6e0e2febef Mon Sep 17 00:00:00 2001 From: snullp Date: Mon, 9 Dec 2024 05:17:58 +0000 Subject: [PATCH] Fix admin/user pagination Integer division floor the page count but the ceil operation is needed. Implemented without float conversion. --- admin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin.go b/admin.go index 258d0b8..6e0f3d5 100644 --- a/admin.go +++ b/admin.go @@ -208,7 +208,7 @@ func handleViewAdminUsers(app *App, u *User, w http.ResponseWriter, r *http.Requ p.Flashes, _ = getSessionFlashes(app, w, r, nil) p.TotalUsers = app.db.GetAllUsersCount() - ttlPages := p.TotalUsers / adminUsersPerPage + ttlPages := (p.TotalUsers - 1) / adminUsersPerPage + 1 p.TotalPages = []int{} for i := 1; i <= int(ttlPages); i++ { p.TotalPages = append(p.TotalPages, i)