Skip to content

Commit

Permalink
Fix pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
jm8 committed Nov 8, 2024
1 parent 876802d commit 8cf1a70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"time"
)

func ceilDiv(a, b int) int {
return (a + b - 1) / b
}

func (r *Router) EnforceAdminMiddleware(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
userId, _ := getUserIDFromContext(req.Context())
Expand Down Expand Up @@ -189,7 +193,7 @@ func (r *Router) adminUsers(w http.ResponseWriter, req *http.Request) {
http.Error(w, "Failed to get users", http.StatusInternalServerError)
return
}
totalPages := totalUsers / 50
totalPages := ceilDiv(totalUsers, 50)
pageNumbers := make([]int, totalPages)
for i := range pageNumbers {
pageNumbers[i] = i + 1
Expand Down

0 comments on commit 8cf1a70

Please sign in to comment.