From 95bebb01cb3ac6afbebd6f1be42ba846761cfa37 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Fri, 10 Sep 2021 14:52:56 +0300 Subject: [PATCH] fix: pagination count --- controllers/threads_controller.go | 2 ++ main.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index b919417..232a702 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -12,6 +12,7 @@ import ( ) func GetThreads(c *gin.Context) { + // TODO: fix empty query pageString := c.Query("page") page, err := strconv.Atoi(pageString) if err != nil { @@ -34,6 +35,7 @@ func GetThreads(c *gin.Context) { return } + // TODO: if page > pagescount render 404 data := Repositories.IndexPageData{ Threads: threads, PagesCount: int(math.Ceil(float64(count) / 10)), diff --git a/main.go b/main.go index b5a03a4..a762a50 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ func main() { "Iterate": func(count int) []int { var i int var Items []int - for i = 1; i < count; i++ { + for i = 1; i < count+1; i++ { Items = append(Items, i) } return Items