update project and selectors
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user