update project and selectors

This commit is contained in:
2025-01-28 17:07:05 +01:00
parent 430892a512
commit 34d1088d9d
15 changed files with 325 additions and 254 deletions
+4 -16
View File
@@ -1,30 +1,18 @@
package handlers
import (
"net/http"
"gopher-toolbox/app"
"github.com/gofiber/fiber/v2"
"github.com/zepyrshut/rating-orama/internal/app"
"github.com/zepyrshut/rating-orama/internal/repository"
)
type Handlers struct {
app *app.App
app *app.ExtendedApp
queries repository.ExtendedQuerier
}
func New(app *app.App, q repository.ExtendedQuerier) *Handlers {
func New(r repository.ExtendedQuerier, app *app.ExtendedApp) *Handlers {
return &Handlers{
app: app,
queries: q,
queries: r,
}
}
func (hq *Handlers) ToBeImplemented(c *fiber.Ctx) error {
return c.Status(http.StatusNotImplemented).JSON("not implemented")
}
func (hq *Handlers) Ping(c *fiber.Ctx) error {
return c.JSON("pong")
}
+5 -1
View File
@@ -13,6 +13,10 @@ import (
func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
ttShowID := c.Query("ttid")
if ttShowID == "" {
return c.SendStatus(http.StatusBadRequest)
}
var title string
var scraperEpisodes []scraper.Episode
var sqlcEpisodes []sqlc.Episode
@@ -20,7 +24,7 @@ func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
tvShow, err := hq.queries.CheckTVShowExists(c.Context(), ttShowID)
if err != nil {
title, scraperEpisodes = scraper.ScrapeEpisodes(ttShowID)
// TODO: make transactional
//TODO: make transactional
ttShow, err := hq.queries.CreateTVShow(c.Context(), sqlc.CreateTVShowParams{
TtImdb: ttShowID,
Name: title,