feat: ✨ almost done
frontend missing yet
This commit is contained in:
@@ -9,15 +9,15 @@ import (
|
||||
)
|
||||
|
||||
type Episode struct {
|
||||
ID int32 `json:"id"`
|
||||
TvShowID int32 `json:"tv_show_id"`
|
||||
Season int32 `json:"season"`
|
||||
Episode int32 `json:"episode"`
|
||||
Released pgtype.Date `json:"released"`
|
||||
Name string `json:"name"`
|
||||
Plot string `json:"plot"`
|
||||
AvgRating pgtype.Numeric `json:"avg_rating"`
|
||||
VoteCount int32 `json:"vote_count"`
|
||||
ID int32 `json:"id"`
|
||||
TvShowID int32 `json:"tv_show_id"`
|
||||
Season int32 `json:"season"`
|
||||
Episode int32 `json:"episode"`
|
||||
Released pgtype.Date `json:"released"`
|
||||
Name string `json:"name"`
|
||||
Plot string `json:"plot"`
|
||||
AvgRating float32 `json:"avg_rating"`
|
||||
VoteCount int32 `json:"vote_count"`
|
||||
}
|
||||
|
||||
type TvShow struct {
|
||||
|
||||
@@ -13,7 +13,7 @@ type Querier interface {
|
||||
CreateEpisodes(ctx context.Context, arg CreateEpisodesParams) (Episode, error)
|
||||
CreateTVShow(ctx context.Context, arg CreateTVShowParams) (TvShow, error)
|
||||
GetEpisodes(ctx context.Context, tvShowID int32) ([]Episode, error)
|
||||
IncreasePopularity(ctx context.Context, id int32) error
|
||||
IncreasePopularity(ctx context.Context, ttImdb string) error
|
||||
SeasonAverageRating(ctx context.Context, arg SeasonAverageRatingParams) (float64, error)
|
||||
TvShowAverageRating(ctx context.Context, tvShowID int32) (float64, error)
|
||||
TvShowMedianRating(ctx context.Context, tvShowID int32) (float64, error)
|
||||
|
||||
@@ -37,14 +37,14 @@ returning id, tv_show_id, season, episode, released, name, plot, avg_rating, vot
|
||||
`
|
||||
|
||||
type CreateEpisodesParams struct {
|
||||
TvShowID int32 `json:"tv_show_id"`
|
||||
Season int32 `json:"season"`
|
||||
Episode int32 `json:"episode"`
|
||||
Released pgtype.Date `json:"released"`
|
||||
Name string `json:"name"`
|
||||
Plot string `json:"plot"`
|
||||
AvgRating pgtype.Numeric `json:"avg_rating"`
|
||||
VoteCount int32 `json:"vote_count"`
|
||||
TvShowID int32 `json:"tv_show_id"`
|
||||
Season int32 `json:"season"`
|
||||
Episode int32 `json:"episode"`
|
||||
Released pgtype.Date `json:"released"`
|
||||
Name string `json:"name"`
|
||||
Plot string `json:"plot"`
|
||||
AvgRating float32 `json:"avg_rating"`
|
||||
VoteCount int32 `json:"vote_count"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateEpisodes(ctx context.Context, arg CreateEpisodesParams) (Episode, error) {
|
||||
@@ -135,11 +135,11 @@ func (q *Queries) GetEpisodes(ctx context.Context, tvShowID int32) ([]Episode, e
|
||||
|
||||
const increasePopularity = `-- name: IncreasePopularity :exec
|
||||
update "tv_show" set popularity = popularity + 1
|
||||
where id = $1
|
||||
where tt_imdb = $1
|
||||
`
|
||||
|
||||
func (q *Queries) IncreasePopularity(ctx context.Context, id int32) error {
|
||||
_, err := q.db.Exec(ctx, increasePopularity, id)
|
||||
func (q *Queries) IncreasePopularity(ctx context.Context, ttImdb string) error {
|
||||
_, err := q.db.Exec(ctx, increasePopularity, ttImdb)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user