Skip to content

Commit

Permalink
refactor(feed): update page query
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Sep 28, 2024
1 parent d88b2f9 commit 62cded5
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"believer/movies/utils"
"believer/movies/views"
"os"
"strconv"
"time"

"github.com/gofiber/fiber/v2"
Expand All @@ -17,8 +16,7 @@ import (
func HandleFeed(c *fiber.Ctx) error {
var movies types.Movies

pageQuery := c.Query("page", "1")
page, err := strconv.Atoi(pageQuery)
page := c.QueryInt("page", 1)
searchQuery := c.Query("search")

if searchQuery != "" {
Expand All @@ -28,14 +26,10 @@ func HandleFeed(c *fiber.Ctx) error {
return err
}
} else {
if err != nil {
page = 1
}

err = db.Dot.Select(db.Client, &movies, "feed", (page-1)*20, c.Locals("UserId"))
err := db.Dot.Select(db.Client, &movies, "feed", (page-1)*20, c.Locals("UserId"))

if err != nil {
panic(err)
return err
}
}

Expand Down

0 comments on commit 62cded5

Please sign in to comment.