Squash merge audio-player-component into main
This commit is contained in:
@@ -1,29 +1,76 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: release_groups.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createReleaseGroup = `-- name: CreateReleaseGroup :one
|
||||
INSERT INTO release_groups (name) VALUES (?)
|
||||
RETURNING id, name, cover_art_id
|
||||
RETURNING id, name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs
|
||||
`
|
||||
|
||||
func (q *Queries) CreateReleaseGroup(ctx context.Context, name string) (ReleaseGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, createReleaseGroup, name)
|
||||
var i ReleaseGroup
|
||||
err := row.Scan(&i.ID, &i.Name, &i.CoverArtID)
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CoverArtID,
|
||||
&i.AlbumArtistCreditID,
|
||||
&i.Year,
|
||||
&i.TotalTracks,
|
||||
&i.TotalDiscs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createReleaseGroupFull = `-- name: CreateReleaseGroupFull :one
|
||||
INSERT INTO release_groups (
|
||||
name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
RETURNING id, name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs
|
||||
`
|
||||
|
||||
type CreateReleaseGroupFullParams struct {
|
||||
Name string
|
||||
CoverArtID sql.NullInt64
|
||||
AlbumArtistCreditID sql.NullInt64
|
||||
Year sql.NullInt64
|
||||
TotalTracks sql.NullInt64
|
||||
TotalDiscs sql.NullInt64
|
||||
}
|
||||
|
||||
func (q *Queries) CreateReleaseGroupFull(ctx context.Context, arg CreateReleaseGroupFullParams) (ReleaseGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, createReleaseGroupFull,
|
||||
arg.Name,
|
||||
arg.CoverArtID,
|
||||
arg.AlbumArtistCreditID,
|
||||
arg.Year,
|
||||
arg.TotalTracks,
|
||||
arg.TotalDiscs,
|
||||
)
|
||||
var i ReleaseGroup
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CoverArtID,
|
||||
&i.AlbumArtistCreditID,
|
||||
&i.Year,
|
||||
&i.TotalTracks,
|
||||
&i.TotalDiscs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteReleaseGroup = `-- name: DeleteReleaseGroup :exec
|
||||
DELETE FROM release_groups
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteReleaseGroup(ctx context.Context, id int64) error {
|
||||
@@ -31,22 +78,136 @@ func (q *Queries) DeleteReleaseGroup(ctx context.Context, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllAlbumsWithDetails = `-- name: GetAllAlbumsWithDetails :many
|
||||
SELECT
|
||||
rg.id,
|
||||
rg.name,
|
||||
rg.year,
|
||||
COALESCE(ac.text, '') as artist_name,
|
||||
COALESCE(ca.file_path, '') as cover_art_path
|
||||
FROM release_groups rg
|
||||
LEFT JOIN artist_credit ac ON rg.album_artist_credit_id = ac.id
|
||||
LEFT JOIN cover_art ca ON rg.cover_art_id = ca.id
|
||||
ORDER BY rg.name
|
||||
`
|
||||
|
||||
type GetAllAlbumsWithDetailsRow struct {
|
||||
ID int64
|
||||
Name string
|
||||
Year sql.NullInt64
|
||||
ArtistName string
|
||||
CoverArtPath string
|
||||
}
|
||||
|
||||
func (q *Queries) GetAllAlbumsWithDetails(ctx context.Context) ([]GetAllAlbumsWithDetailsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllAlbumsWithDetails)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetAllAlbumsWithDetailsRow
|
||||
for rows.Next() {
|
||||
var i GetAllAlbumsWithDetailsRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Year,
|
||||
&i.ArtistName,
|
||||
&i.CoverArtPath,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAllReleaseGroups = `-- name: GetAllReleaseGroups :many
|
||||
SELECT id, name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs FROM release_groups
|
||||
ORDER BY name
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllReleaseGroups(ctx context.Context) ([]ReleaseGroup, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllReleaseGroups)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ReleaseGroup
|
||||
for rows.Next() {
|
||||
var i ReleaseGroup
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CoverArtID,
|
||||
&i.AlbumArtistCreditID,
|
||||
&i.Year,
|
||||
&i.TotalTracks,
|
||||
&i.TotalDiscs,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getReleaseGroup = `-- name: GetReleaseGroup :one
|
||||
SELECT id, name, cover_art_id FROM release_groups
|
||||
SELECT id, name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs FROM release_groups
|
||||
WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetReleaseGroup(ctx context.Context, id int64) (ReleaseGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, getReleaseGroup, id)
|
||||
var i ReleaseGroup
|
||||
err := row.Scan(&i.ID, &i.Name, &i.CoverArtID)
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CoverArtID,
|
||||
&i.AlbumArtistCreditID,
|
||||
&i.Year,
|
||||
&i.TotalTracks,
|
||||
&i.TotalDiscs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getReleaseGroupByName = `-- name: GetReleaseGroupByName :one
|
||||
SELECT id, name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs FROM release_groups
|
||||
WHERE name = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetReleaseGroupByName(ctx context.Context, name string) (ReleaseGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, getReleaseGroupByName, name)
|
||||
var i ReleaseGroup
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CoverArtID,
|
||||
&i.AlbumArtistCreditID,
|
||||
&i.Year,
|
||||
&i.TotalTracks,
|
||||
&i.TotalDiscs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateReleaseGroup = `-- name: UpdateReleaseGroup :exec
|
||||
UPDATE release_groups
|
||||
SET name = ?
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateReleaseGroupParams struct {
|
||||
@@ -58,3 +219,49 @@ func (q *Queries) UpdateReleaseGroup(ctx context.Context, arg UpdateReleaseGroup
|
||||
_, err := q.db.ExecContext(ctx, updateReleaseGroup, arg.Name, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateReleaseGroupCoverArt = `-- name: UpdateReleaseGroupCoverArt :exec
|
||||
UPDATE release_groups
|
||||
SET cover_art_id = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateReleaseGroupCoverArtParams struct {
|
||||
CoverArtID sql.NullInt64
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateReleaseGroupCoverArt(ctx context.Context, arg UpdateReleaseGroupCoverArtParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateReleaseGroupCoverArt, arg.CoverArtID, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertReleaseGroup = `-- name: UpsertReleaseGroup :one
|
||||
INSERT INTO release_groups (name, album_artist_credit_id, year)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(name) DO UPDATE SET
|
||||
album_artist_credit_id = COALESCE(excluded.album_artist_credit_id, release_groups.album_artist_credit_id),
|
||||
year = COALESCE(excluded.year, release_groups.year)
|
||||
RETURNING id, name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs
|
||||
`
|
||||
|
||||
type UpsertReleaseGroupParams struct {
|
||||
Name string
|
||||
AlbumArtistCreditID sql.NullInt64
|
||||
Year sql.NullInt64
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertReleaseGroup(ctx context.Context, arg UpsertReleaseGroupParams) (ReleaseGroup, error) {
|
||||
row := q.db.QueryRowContext(ctx, upsertReleaseGroup, arg.Name, arg.AlbumArtistCreditID, arg.Year)
|
||||
var i ReleaseGroup
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CoverArtID,
|
||||
&i.AlbumArtistCreditID,
|
||||
&i.Year,
|
||||
&i.TotalTracks,
|
||||
&i.TotalDiscs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user