fix: pagination count

This commit is contained in:
Yanislav Igonin 2021-09-10 14:52:56 +03:00
parent 9b69eb46b7
commit 95bebb01cb
2 changed files with 3 additions and 1 deletions

View File

@ -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)),

View File

@ -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