mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
fix: pagination count
This commit is contained in:
parent
9b69eb46b7
commit
95bebb01cb
@ -12,6 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetThreads(c *gin.Context) {
|
func GetThreads(c *gin.Context) {
|
||||||
|
// TODO: fix empty query
|
||||||
pageString := c.Query("page")
|
pageString := c.Query("page")
|
||||||
page, err := strconv.Atoi(pageString)
|
page, err := strconv.Atoi(pageString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -34,6 +35,7 @@ func GetThreads(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: if page > pagescount render 404
|
||||||
data := Repositories.IndexPageData{
|
data := Repositories.IndexPageData{
|
||||||
Threads: threads,
|
Threads: threads,
|
||||||
PagesCount: int(math.Ceil(float64(count) / 10)),
|
PagesCount: int(math.Ceil(float64(count) / 10)),
|
||||||
|
2
main.go
2
main.go
@ -46,7 +46,7 @@ func main() {
|
|||||||
"Iterate": func(count int) []int {
|
"Iterate": func(count int) []int {
|
||||||
var i int
|
var i int
|
||||||
var Items []int
|
var Items []int
|
||||||
for i = 1; i < count; i++ {
|
for i = 1; i < count+1; i++ {
|
||||||
Items = append(Items, i)
|
Items = append(Items, i)
|
||||||
}
|
}
|
||||||
return Items
|
return Items
|
||||||
|
Loading…
Reference in New Issue
Block a user