Squash merge audio-player-component into main
This commit is contained in:
@@ -6,12 +6,20 @@ RETURNING *;
|
||||
SELECT * FROM artist_credit
|
||||
WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: GetArtistCreditByText :one
|
||||
SELECT * FROM artist_credit
|
||||
WHERE text = ? LIMIT 1;
|
||||
|
||||
-- name: UpsertArtistCredit :one
|
||||
INSERT INTO artist_credit (text) VALUES (?)
|
||||
ON CONFLICT(text) DO UPDATE SET text = excluded.text
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateArtistCredit :exec
|
||||
UPDATE artist_credit
|
||||
SET text = ?
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteArtistCredit :exec
|
||||
DELETE FROM artist_credit
|
||||
WHERE id =?;
|
||||
|
||||
WHERE id = ?;
|
||||
|
||||
@@ -6,12 +6,24 @@ RETURNING *;
|
||||
SELECT * FROM artists
|
||||
WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: GetArtistByName :one
|
||||
SELECT * FROM artists
|
||||
WHERE name = ? LIMIT 1;
|
||||
|
||||
-- name: UpsertArtist :one
|
||||
INSERT INTO artists (name) VALUES (?)
|
||||
ON CONFLICT(name) DO UPDATE SET name = excluded.name
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateArtist :exec
|
||||
UPDATE artists
|
||||
SET name = ?
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteArtist :exec
|
||||
DELETE FROM artists
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: GetAllArtists :many
|
||||
SELECT * FROM artists
|
||||
ORDER BY name;
|
||||
|
||||
@@ -6,12 +6,82 @@ RETURNING *;
|
||||
SELECT * FROM audio_files
|
||||
WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: GetAudioFileByPath :one
|
||||
SELECT * FROM audio_files
|
||||
WHERE file_path = ? LIMIT 1;
|
||||
|
||||
-- name: UpdateAudioFile :exec
|
||||
UPDATE audio_files
|
||||
SET file_path = ?, length_milliseconds = ?, file_type_id = ?, recording_id = ?
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: UpdateAudioFileRecording :exec
|
||||
UPDATE audio_files
|
||||
SET recording_id = ?
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteAudioFile :exec
|
||||
DELETE FROM audio_files
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: CountAudioFiles :one
|
||||
SELECT count(*) FROM audio_files;
|
||||
|
||||
-- name: GetRandomAudioFilePath :one
|
||||
SELECT file_path FROM audio_files
|
||||
ORDER BY RANDOM()
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetAllAudioFiles :many
|
||||
SELECT * FROM audio_files;
|
||||
|
||||
-- name: GetAllAudioFilePaths :many
|
||||
SELECT id, file_path FROM audio_files;
|
||||
|
||||
-- name: GetAudioFilesNeedingMetadata :many
|
||||
SELECT * FROM audio_files
|
||||
WHERE recording_id = 0;
|
||||
|
||||
-- name: GetAllAudioFilesWithArtist :many
|
||||
SELECT
|
||||
af.id,
|
||||
af.file_path,
|
||||
af.length_milliseconds,
|
||||
af.file_type_id,
|
||||
af.recording_id,
|
||||
COALESCE(ac.text, '') AS artist_name,
|
||||
COALESCE(r.name, '') AS title
|
||||
FROM audio_files af
|
||||
JOIN recordings r ON af.recording_id = r.id
|
||||
JOIN artist_credit ac ON r.artist_credit_id = ac.id;
|
||||
|
||||
-- name: GetTrackMetadataByPath :one
|
||||
SELECT
|
||||
af.file_path,
|
||||
COALESCE(r.name, '') AS title,
|
||||
COALESCE(ac.text, '') AS artist,
|
||||
COALESCE(rg.name, '') AS album,
|
||||
COALESCE(ca.file_path, '') AS cover_art_path
|
||||
FROM audio_files af
|
||||
LEFT JOIN recordings r ON af.recording_id = r.id
|
||||
LEFT JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
LEFT JOIN release_group_recordings rgr ON r.id = rgr.recording_id
|
||||
LEFT JOIN release_groups rg ON rgr.release_group_id = rg.id
|
||||
LEFT JOIN cover_art ca ON rg.cover_art_id = ca.id
|
||||
WHERE af.file_path = ?
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetAudioFilesByReleaseGroup :many
|
||||
SELECT
|
||||
af.file_path,
|
||||
af.length_milliseconds,
|
||||
COALESCE(r.name, '') AS title,
|
||||
COALESCE(ac.text, '') AS artist_name,
|
||||
rgr.track_number,
|
||||
rgr.disc_number
|
||||
FROM release_group_recordings rgr
|
||||
JOIN recordings r ON rgr.recording_id = r.id
|
||||
JOIN audio_files af ON af.recording_id = r.id
|
||||
LEFT JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
WHERE rgr.release_group_id = ?
|
||||
ORDER BY rgr.disc_number, rgr.track_number;
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
-- name: CreateCoverArt :one
|
||||
INSERT INTO cover_art (is_embedded, file_path, file_type_id) VALUES (?, ?, ?)
|
||||
INSERT INTO cover_art (is_embedded, file_path, mime_type) VALUES (?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetCoverArt :one
|
||||
SELECT * FROM cover_art
|
||||
WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: GetCoverArtByPath :one
|
||||
SELECT * FROM cover_art
|
||||
WHERE file_path = ? LIMIT 1;
|
||||
|
||||
-- name: UpsertCoverArt :one
|
||||
INSERT INTO cover_art (is_embedded, file_path, mime_type)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(file_path) DO UPDATE SET
|
||||
is_embedded = excluded.is_embedded,
|
||||
mime_type = excluded.mime_type
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateCoverArt :exec
|
||||
UPDATE cover_art
|
||||
SET is_embedded = ?, file_path = ?, file_type_id = ?
|
||||
WHERE id =?;
|
||||
SET is_embedded = ?, file_path = ?, mime_type = ?
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteCoverArt :exec
|
||||
DELETE FROM cover_art
|
||||
WHERE id =?;
|
||||
|
||||
WHERE id = ?;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
-- name: GetPlayerState :one
|
||||
SELECT volume, muted, last_track_path, last_position_seconds
|
||||
FROM player_state WHERE id = 1;
|
||||
|
||||
-- name: UpdatePlayerState :exec
|
||||
UPDATE player_state
|
||||
SET volume = ?, muted = ?, last_track_path = ?, last_position_seconds = ?
|
||||
WHERE id = 1;
|
||||
@@ -0,0 +1,32 @@
|
||||
-- name: CreatePlaylist :one
|
||||
INSERT INTO playlists (name) VALUES (?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetPlaylist :one
|
||||
SELECT * FROM playlists WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: GetAllPlaylists :many
|
||||
SELECT * FROM playlists ORDER BY updated_at DESC;
|
||||
|
||||
-- name: UpdatePlaylistName :exec
|
||||
UPDATE playlists SET name = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?;
|
||||
|
||||
-- name: DeletePlaylist :exec
|
||||
DELETE FROM playlists WHERE id = ?;
|
||||
|
||||
-- name: AddPlaylistTrack :one
|
||||
INSERT INTO playlist_tracks (playlist_id, audio_file_id, position) VALUES (?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetPlaylistTracks :many
|
||||
SELECT pt.id, pt.playlist_id, pt.audio_file_id, pt.position, af.file_path
|
||||
FROM playlist_tracks pt
|
||||
JOIN audio_files af ON pt.audio_file_id = af.id
|
||||
WHERE pt.playlist_id = ?
|
||||
ORDER BY pt.position;
|
||||
|
||||
-- name: RemovePlaylistTrack :exec
|
||||
DELETE FROM playlist_tracks WHERE id = ?;
|
||||
|
||||
-- name: ClearPlaylistTracks :exec
|
||||
DELETE FROM playlist_tracks WHERE playlist_id = ?;
|
||||
@@ -0,0 +1,49 @@
|
||||
-- name: GetQueueState :one
|
||||
SELECT source_playlist_id, current_position, shuffle_mode, repeat_mode, shuffle_order
|
||||
FROM queue WHERE id = 1;
|
||||
|
||||
-- name: UpdateQueueState :exec
|
||||
UPDATE queue
|
||||
SET source_playlist_id = ?, current_position = ?, shuffle_mode = ?, repeat_mode = ?, shuffle_order = ?
|
||||
WHERE id = 1;
|
||||
|
||||
-- name: UpdateQueuePosition :exec
|
||||
UPDATE queue
|
||||
SET current_position = ?
|
||||
WHERE id = 1;
|
||||
|
||||
-- name: GetQueueTracks :many
|
||||
SELECT qt.id, qt.audio_file_id, qt.position, af.file_path,
|
||||
COALESCE(r.name, '') AS title,
|
||||
COALESCE(ac.text, '') AS artist
|
||||
FROM queue_tracks qt
|
||||
JOIN audio_files af ON qt.audio_file_id = af.id
|
||||
LEFT JOIN recordings r ON af.recording_id = r.id
|
||||
LEFT JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
ORDER BY qt.position;
|
||||
|
||||
-- name: GetQueueTrackCount :one
|
||||
SELECT count(*) FROM queue_tracks;
|
||||
|
||||
-- name: InsertQueueTrack :one
|
||||
INSERT INTO queue_tracks (audio_file_id, position) VALUES (?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: ClearQueueTracks :exec
|
||||
DELETE FROM queue_tracks;
|
||||
|
||||
-- name: RemoveQueueTrack :exec
|
||||
DELETE FROM queue_tracks WHERE id = ?;
|
||||
|
||||
-- name: RemoveQueueTrackByPosition :exec
|
||||
DELETE FROM queue_tracks WHERE position = ?;
|
||||
|
||||
-- name: ShiftQueuePositionsDown :exec
|
||||
UPDATE queue_tracks
|
||||
SET position = position - 1
|
||||
WHERE position > ?;
|
||||
|
||||
-- name: ShiftQueuePositionsUp :exec
|
||||
UPDATE queue_tracks
|
||||
SET position = position + 1
|
||||
WHERE position >= ?;
|
||||
@@ -1,5 +1,12 @@
|
||||
-- name: CreateRecording :one
|
||||
INSERT INTO recordings (name) VALUES (?)
|
||||
INSERT INTO recordings (name, artist_credit_id) VALUES (?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: CreateRecordingFull :one
|
||||
INSERT INTO recordings (
|
||||
name, artist_credit_id, track_number, disc_number,
|
||||
year, genre, composer, lyrics, comment
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetRecording :one
|
||||
@@ -8,10 +15,19 @@ WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: UpdateRecording :exec
|
||||
UPDATE recordings
|
||||
SET name = ?
|
||||
WHERE id =?;
|
||||
SET name = ?, artist_credit_id = ?
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: UpdateRecordingFull :exec
|
||||
UPDATE recordings
|
||||
SET name = ?, artist_credit_id = ?, track_number = ?, disc_number = ?,
|
||||
year = ?, genre = ?, composer = ?, lyrics = ?, comment = ?
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteRecording :exec
|
||||
DELETE FROM recordings
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: GetAllRecordings :many
|
||||
SELECT * FROM recordings
|
||||
ORDER BY name;
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
-- name: CreateReleaseGroupRecording :one
|
||||
INSERT INTO release_group_recordings (release_group_id, recording_id) VALUES (?,?)
|
||||
INSERT INTO release_group_recordings (release_group_id, recording_id, track_number, disc_number)
|
||||
VALUES (?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetReleaseGroupRecording :one
|
||||
SELECT * FROM release_group_recordings
|
||||
WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: UpdateReleaseGroupRecording :exec
|
||||
UPDATE release_group_recordings
|
||||
SET release_group_id = ?, recording_id = ?
|
||||
WHERE id =?;
|
||||
-- name: GetReleaseGroupRecordings :many
|
||||
SELECT * FROM release_group_recordings
|
||||
WHERE release_group_id = ?
|
||||
ORDER BY disc_number, track_number;
|
||||
|
||||
-- name: GetRecordingReleaseGroups :many
|
||||
SELECT * FROM release_group_recordings
|
||||
WHERE recording_id = ?;
|
||||
|
||||
-- name: DeleteReleaseGroupRecording :exec
|
||||
DELETE FROM release_group_recordings
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteReleaseGroupRecordingByFK :exec
|
||||
DELETE FROM release_group_recordings
|
||||
WHERE release_group_id = ? AND recording_id = ?;
|
||||
|
||||
@@ -2,16 +2,54 @@
|
||||
INSERT INTO release_groups (name) VALUES (?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: CreateReleaseGroupFull :one
|
||||
INSERT INTO release_groups (
|
||||
name, cover_art_id, album_artist_credit_id, year, total_tracks, total_discs
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetReleaseGroup :one
|
||||
SELECT * FROM release_groups
|
||||
WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: GetReleaseGroupByName :one
|
||||
SELECT * FROM release_groups
|
||||
WHERE name = ? LIMIT 1;
|
||||
|
||||
-- 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 *;
|
||||
|
||||
-- name: UpdateReleaseGroup :exec
|
||||
UPDATE release_groups
|
||||
SET name = ?
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: UpdateReleaseGroupCoverArt :exec
|
||||
UPDATE release_groups
|
||||
SET cover_art_id = ?
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: DeleteReleaseGroup :exec
|
||||
DELETE FROM release_groups
|
||||
WHERE id =?;
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: GetAllReleaseGroups :many
|
||||
SELECT * FROM release_groups
|
||||
ORDER BY name;
|
||||
|
||||
-- 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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS artist_credit (
|
||||
id int PRIMARY KEY,
|
||||
text string NOT NULL
|
||||
id INTEGER PRIMARY KEY,
|
||||
text TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS artist_credit_artist (
|
||||
id int PRIMARY KEY,
|
||||
id integer PRIMARY KEY,
|
||||
artist_id int NOT NULL,
|
||||
credit_id int NOT NULL,
|
||||
FOREIGN KEY(artist_id) REFERENCES artists(id),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS artists (
|
||||
id int PRIMARY KEY,
|
||||
name text NOT NULL
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS audio_files (
|
||||
id int PRIMARY KEY,
|
||||
id integer PRIMARY KEY,
|
||||
file_path text NOT NULL UNIQUE,
|
||||
length_milliseconds int NOT NULL,
|
||||
file_type_id int NOT NULL,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS cover_art (
|
||||
id int PRIMARY KEY,
|
||||
is_embedded bool NOT NULL DEFAULT(false),
|
||||
file_path text NOT NULL,
|
||||
file_type_id int NOT NULL,
|
||||
FOREIGN KEY(file_type_id) REFERENCES file_types(id)
|
||||
id INTEGER PRIMARY KEY,
|
||||
is_embedded BOOL NOT NULL DEFAULT(false),
|
||||
file_path TEXT NOT NULL UNIQUE,
|
||||
mime_type TEXT NOT NULL
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS file_types (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id integer PRIMARY KEY,
|
||||
extension text NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS player_state (
|
||||
id INTEGER PRIMARY KEY CHECK(id = 1),
|
||||
volume INTEGER NOT NULL DEFAULT 100,
|
||||
muted BOOLEAN NOT NULL DEFAULT false,
|
||||
last_track_path TEXT NOT NULL DEFAULT '',
|
||||
last_position_seconds INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO player_state (id) VALUES (1);
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS playlist_tracks (
|
||||
id INTEGER PRIMARY KEY,
|
||||
playlist_id INTEGER NOT NULL,
|
||||
audio_file_id INTEGER NOT NULL,
|
||||
position INTEGER NOT NULL,
|
||||
FOREIGN KEY(playlist_id) REFERENCES playlists(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(audio_file_id) REFERENCES audio_files(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS playlists (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS queue (
|
||||
id INTEGER PRIMARY KEY CHECK(id = 1),
|
||||
source_playlist_id INTEGER,
|
||||
current_position INTEGER NOT NULL DEFAULT 0,
|
||||
shuffle_mode BOOLEAN NOT NULL DEFAULT false,
|
||||
repeat_mode TEXT NOT NULL DEFAULT 'off',
|
||||
shuffle_order TEXT,
|
||||
FOREIGN KEY(source_playlist_id) REFERENCES playlists(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO queue (id) VALUES (1);
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS queue_tracks (
|
||||
id INTEGER PRIMARY KEY,
|
||||
audio_file_id INTEGER NOT NULL,
|
||||
position INTEGER NOT NULL,
|
||||
FOREIGN KEY(audio_file_id) REFERENCES audio_files(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -1,7 +1,13 @@
|
||||
CREATE TABLE IF NOT EXISTS recordings (
|
||||
id int PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
artist_credit_id int NOT NULL,
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
artist_credit_id INTEGER NOT NULL,
|
||||
track_number INTEGER,
|
||||
disc_number INTEGER,
|
||||
year INTEGER,
|
||||
genre TEXT,
|
||||
composer TEXT,
|
||||
lyrics TEXT,
|
||||
comment TEXT,
|
||||
FOREIGN KEY(artist_credit_id) REFERENCES artist_credit(id)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS release_group_recordings (
|
||||
id int PRIMARY KEY,
|
||||
release_group_id int NOT NULL,
|
||||
recording_id int NOT NULL,
|
||||
id INTEGER PRIMARY KEY,
|
||||
release_group_id INTEGER NOT NULL,
|
||||
recording_id INTEGER NOT NULL,
|
||||
track_number INTEGER,
|
||||
disc_number INTEGER,
|
||||
FOREIGN KEY(release_group_id) REFERENCES release_groups(id),
|
||||
FOREIGN KEY(recording_id) REFERENCES recordings(id)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS release_groups (
|
||||
id int PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
cover_art_id int NOT NULL,
|
||||
FOREIGN KEY(cover_art_id) REFERENCES cover_art(id)
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
cover_art_id INTEGER,
|
||||
album_artist_credit_id INTEGER,
|
||||
year INTEGER,
|
||||
total_tracks INTEGER,
|
||||
total_discs INTEGER,
|
||||
FOREIGN KEY(cover_art_id) REFERENCES cover_art(id),
|
||||
FOREIGN KEY(album_artist_credit_id) REFERENCES artist_credit(id)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: artist_credit.sql
|
||||
|
||||
package sqlcgen
|
||||
@@ -14,7 +14,7 @@ INSERT INTO artist_credit (text) VALUES (?)
|
||||
RETURNING id, text
|
||||
`
|
||||
|
||||
func (q *Queries) CreateArtistCredit(ctx context.Context, text interface{}) (ArtistCredit, error) {
|
||||
func (q *Queries) CreateArtistCredit(ctx context.Context, text string) (ArtistCredit, error) {
|
||||
row := q.db.QueryRowContext(ctx, createArtistCredit, text)
|
||||
var i ArtistCredit
|
||||
err := row.Scan(&i.ID, &i.Text)
|
||||
@@ -23,7 +23,7 @@ func (q *Queries) CreateArtistCredit(ctx context.Context, text interface{}) (Art
|
||||
|
||||
const deleteArtistCredit = `-- name: DeleteArtistCredit :exec
|
||||
DELETE FROM artist_credit
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteArtistCredit(ctx context.Context, id int64) error {
|
||||
@@ -43,14 +43,26 @@ func (q *Queries) GetArtistCredit(ctx context.Context, id int64) (ArtistCredit,
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getArtistCreditByText = `-- name: GetArtistCreditByText :one
|
||||
SELECT id, text FROM artist_credit
|
||||
WHERE text = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetArtistCreditByText(ctx context.Context, text string) (ArtistCredit, error) {
|
||||
row := q.db.QueryRowContext(ctx, getArtistCreditByText, text)
|
||||
var i ArtistCredit
|
||||
err := row.Scan(&i.ID, &i.Text)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateArtistCredit = `-- name: UpdateArtistCredit :exec
|
||||
UPDATE artist_credit
|
||||
SET text = ?
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateArtistCreditParams struct {
|
||||
Text interface{}
|
||||
Text string
|
||||
ID int64
|
||||
}
|
||||
|
||||
@@ -58,3 +70,16 @@ func (q *Queries) UpdateArtistCredit(ctx context.Context, arg UpdateArtistCredit
|
||||
_, err := q.db.ExecContext(ctx, updateArtistCredit, arg.Text, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertArtistCredit = `-- name: UpsertArtistCredit :one
|
||||
INSERT INTO artist_credit (text) VALUES (?)
|
||||
ON CONFLICT(text) DO UPDATE SET text = excluded.text
|
||||
RETURNING id, text
|
||||
`
|
||||
|
||||
func (q *Queries) UpsertArtistCredit(ctx context.Context, text string) (ArtistCredit, error) {
|
||||
row := q.db.QueryRowContext(ctx, upsertArtistCredit, text)
|
||||
var i ArtistCredit
|
||||
err := row.Scan(&i.ID, &i.Text)
|
||||
return i, err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: artist_credit_artists.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: artists.sql
|
||||
|
||||
package sqlcgen
|
||||
@@ -23,7 +23,7 @@ func (q *Queries) CreateArtist(ctx context.Context, name string) (Artist, error)
|
||||
|
||||
const deleteArtist = `-- name: DeleteArtist :exec
|
||||
DELETE FROM artists
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteArtist(ctx context.Context, id int64) error {
|
||||
@@ -31,6 +31,34 @@ func (q *Queries) DeleteArtist(ctx context.Context, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllArtists = `-- name: GetAllArtists :many
|
||||
SELECT id, name FROM artists
|
||||
ORDER BY name
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllArtists(ctx context.Context) ([]Artist, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllArtists)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Artist
|
||||
for rows.Next() {
|
||||
var i Artist
|
||||
if err := rows.Scan(&i.ID, &i.Name); 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 getArtist = `-- name: GetArtist :one
|
||||
SELECT id, name FROM artists
|
||||
WHERE id = ? LIMIT 1
|
||||
@@ -43,10 +71,22 @@ func (q *Queries) GetArtist(ctx context.Context, id int64) (Artist, error) {
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getArtistByName = `-- name: GetArtistByName :one
|
||||
SELECT id, name FROM artists
|
||||
WHERE name = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetArtistByName(ctx context.Context, name string) (Artist, error) {
|
||||
row := q.db.QueryRowContext(ctx, getArtistByName, name)
|
||||
var i Artist
|
||||
err := row.Scan(&i.ID, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateArtist = `-- name: UpdateArtist :exec
|
||||
UPDATE artists
|
||||
SET name = ?
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateArtistParams struct {
|
||||
@@ -58,3 +98,16 @@ func (q *Queries) UpdateArtist(ctx context.Context, arg UpdateArtistParams) erro
|
||||
_, err := q.db.ExecContext(ctx, updateArtist, arg.Name, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertArtist = `-- name: UpsertArtist :one
|
||||
INSERT INTO artists (name) VALUES (?)
|
||||
ON CONFLICT(name) DO UPDATE SET name = excluded.name
|
||||
RETURNING id, name
|
||||
`
|
||||
|
||||
func (q *Queries) UpsertArtist(ctx context.Context, name string) (Artist, error) {
|
||||
row := q.db.QueryRowContext(ctx, upsertArtist, name)
|
||||
var i Artist
|
||||
err := row.Scan(&i.ID, &i.Name)
|
||||
return i, err
|
||||
}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: audio_files.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const countAudioFiles = `-- name: CountAudioFiles :one
|
||||
SELECT count(*) FROM audio_files
|
||||
`
|
||||
|
||||
func (q *Queries) CountAudioFiles(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, countAudioFiles)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const createAudioFile = `-- name: CreateAudioFile :one
|
||||
INSERT INTO audio_files (file_path, length_milliseconds, file_type_id, recording_id) VALUES (?, ?, ?, ?)
|
||||
RETURNING id, file_path, length_milliseconds, file_type_id, recording_id
|
||||
@@ -41,7 +53,7 @@ func (q *Queries) CreateAudioFile(ctx context.Context, arg CreateAudioFileParams
|
||||
|
||||
const deleteAudioFile = `-- name: DeleteAudioFile :exec
|
||||
DELETE FROM audio_files
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAudioFile(ctx context.Context, id int64) error {
|
||||
@@ -49,6 +61,126 @@ func (q *Queries) DeleteAudioFile(ctx context.Context, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllAudioFilePaths = `-- name: GetAllAudioFilePaths :many
|
||||
SELECT id, file_path FROM audio_files
|
||||
`
|
||||
|
||||
type GetAllAudioFilePathsRow struct {
|
||||
ID int64
|
||||
FilePath string
|
||||
}
|
||||
|
||||
func (q *Queries) GetAllAudioFilePaths(ctx context.Context) ([]GetAllAudioFilePathsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllAudioFilePaths)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetAllAudioFilePathsRow
|
||||
for rows.Next() {
|
||||
var i GetAllAudioFilePathsRow
|
||||
if err := rows.Scan(&i.ID, &i.FilePath); 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 getAllAudioFiles = `-- name: GetAllAudioFiles :many
|
||||
SELECT id, file_path, length_milliseconds, file_type_id, recording_id FROM audio_files
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllAudioFiles(ctx context.Context) ([]AudioFile, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllAudioFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []AudioFile
|
||||
for rows.Next() {
|
||||
var i AudioFile
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.FilePath,
|
||||
&i.LengthMilliseconds,
|
||||
&i.FileTypeID,
|
||||
&i.RecordingID,
|
||||
); 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 getAllAudioFilesWithArtist = `-- name: GetAllAudioFilesWithArtist :many
|
||||
SELECT
|
||||
af.id,
|
||||
af.file_path,
|
||||
af.length_milliseconds,
|
||||
af.file_type_id,
|
||||
af.recording_id,
|
||||
COALESCE(ac.text, '') AS artist_name,
|
||||
COALESCE(r.name, '') AS title
|
||||
FROM audio_files af
|
||||
JOIN recordings r ON af.recording_id = r.id
|
||||
JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
`
|
||||
|
||||
type GetAllAudioFilesWithArtistRow struct {
|
||||
ID int64
|
||||
FilePath string
|
||||
LengthMilliseconds int64
|
||||
FileTypeID int64
|
||||
RecordingID int64
|
||||
ArtistName string
|
||||
Title string
|
||||
}
|
||||
|
||||
func (q *Queries) GetAllAudioFilesWithArtist(ctx context.Context) ([]GetAllAudioFilesWithArtistRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllAudioFilesWithArtist)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetAllAudioFilesWithArtistRow
|
||||
for rows.Next() {
|
||||
var i GetAllAudioFilesWithArtistRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.FilePath,
|
||||
&i.LengthMilliseconds,
|
||||
&i.FileTypeID,
|
||||
&i.RecordingID,
|
||||
&i.ArtistName,
|
||||
&i.Title,
|
||||
); 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 getAudioFile = `-- name: GetAudioFile :one
|
||||
SELECT id, file_path, length_milliseconds, file_type_id, recording_id FROM audio_files
|
||||
WHERE id = ? LIMIT 1
|
||||
@@ -67,10 +199,168 @@ func (q *Queries) GetAudioFile(ctx context.Context, id int64) (AudioFile, error)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAudioFileByPath = `-- name: GetAudioFileByPath :one
|
||||
SELECT id, file_path, length_milliseconds, file_type_id, recording_id FROM audio_files
|
||||
WHERE file_path = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAudioFileByPath(ctx context.Context, filePath string) (AudioFile, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAudioFileByPath, filePath)
|
||||
var i AudioFile
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.FilePath,
|
||||
&i.LengthMilliseconds,
|
||||
&i.FileTypeID,
|
||||
&i.RecordingID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAudioFilesByReleaseGroup = `-- name: GetAudioFilesByReleaseGroup :many
|
||||
SELECT
|
||||
af.file_path,
|
||||
af.length_milliseconds,
|
||||
COALESCE(r.name, '') AS title,
|
||||
COALESCE(ac.text, '') AS artist_name,
|
||||
rgr.track_number,
|
||||
rgr.disc_number
|
||||
FROM release_group_recordings rgr
|
||||
JOIN recordings r ON rgr.recording_id = r.id
|
||||
JOIN audio_files af ON af.recording_id = r.id
|
||||
LEFT JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
WHERE rgr.release_group_id = ?
|
||||
ORDER BY rgr.disc_number, rgr.track_number
|
||||
`
|
||||
|
||||
type GetAudioFilesByReleaseGroupRow struct {
|
||||
FilePath string
|
||||
LengthMilliseconds int64
|
||||
Title string
|
||||
ArtistName string
|
||||
TrackNumber sql.NullInt64
|
||||
DiscNumber sql.NullInt64
|
||||
}
|
||||
|
||||
func (q *Queries) GetAudioFilesByReleaseGroup(ctx context.Context, releaseGroupID int64) ([]GetAudioFilesByReleaseGroupRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAudioFilesByReleaseGroup, releaseGroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetAudioFilesByReleaseGroupRow
|
||||
for rows.Next() {
|
||||
var i GetAudioFilesByReleaseGroupRow
|
||||
if err := rows.Scan(
|
||||
&i.FilePath,
|
||||
&i.LengthMilliseconds,
|
||||
&i.Title,
|
||||
&i.ArtistName,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
); 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 getAudioFilesNeedingMetadata = `-- name: GetAudioFilesNeedingMetadata :many
|
||||
SELECT id, file_path, length_milliseconds, file_type_id, recording_id FROM audio_files
|
||||
WHERE recording_id = 0
|
||||
`
|
||||
|
||||
func (q *Queries) GetAudioFilesNeedingMetadata(ctx context.Context) ([]AudioFile, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAudioFilesNeedingMetadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []AudioFile
|
||||
for rows.Next() {
|
||||
var i AudioFile
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.FilePath,
|
||||
&i.LengthMilliseconds,
|
||||
&i.FileTypeID,
|
||||
&i.RecordingID,
|
||||
); 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 getRandomAudioFilePath = `-- name: GetRandomAudioFilePath :one
|
||||
SELECT file_path FROM audio_files
|
||||
ORDER BY RANDOM()
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetRandomAudioFilePath(ctx context.Context) (string, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRandomAudioFilePath)
|
||||
var file_path string
|
||||
err := row.Scan(&file_path)
|
||||
return file_path, err
|
||||
}
|
||||
|
||||
const getTrackMetadataByPath = `-- name: GetTrackMetadataByPath :one
|
||||
SELECT
|
||||
af.file_path,
|
||||
COALESCE(r.name, '') AS title,
|
||||
COALESCE(ac.text, '') AS artist,
|
||||
COALESCE(rg.name, '') AS album,
|
||||
COALESCE(ca.file_path, '') AS cover_art_path
|
||||
FROM audio_files af
|
||||
LEFT JOIN recordings r ON af.recording_id = r.id
|
||||
LEFT JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
LEFT JOIN release_group_recordings rgr ON r.id = rgr.recording_id
|
||||
LEFT JOIN release_groups rg ON rgr.release_group_id = rg.id
|
||||
LEFT JOIN cover_art ca ON rg.cover_art_id = ca.id
|
||||
WHERE af.file_path = ?
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetTrackMetadataByPathRow struct {
|
||||
FilePath string
|
||||
Title string
|
||||
Artist string
|
||||
Album string
|
||||
CoverArtPath string
|
||||
}
|
||||
|
||||
func (q *Queries) GetTrackMetadataByPath(ctx context.Context, filePath string) (GetTrackMetadataByPathRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTrackMetadataByPath, filePath)
|
||||
var i GetTrackMetadataByPathRow
|
||||
err := row.Scan(
|
||||
&i.FilePath,
|
||||
&i.Title,
|
||||
&i.Artist,
|
||||
&i.Album,
|
||||
&i.CoverArtPath,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateAudioFile = `-- name: UpdateAudioFile :exec
|
||||
UPDATE audio_files
|
||||
SET file_path = ?, length_milliseconds = ?, file_type_id = ?, recording_id = ?
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateAudioFileParams struct {
|
||||
@@ -91,3 +381,19 @@ func (q *Queries) UpdateAudioFile(ctx context.Context, arg UpdateAudioFileParams
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateAudioFileRecording = `-- name: UpdateAudioFileRecording :exec
|
||||
UPDATE audio_files
|
||||
SET recording_id = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateAudioFileRecordingParams struct {
|
||||
RecordingID int64
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateAudioFileRecording(ctx context.Context, arg UpdateAudioFileRecordingParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateAudioFileRecording, arg.RecordingID, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: cover_art.sql
|
||||
|
||||
package sqlcgen
|
||||
@@ -10,31 +10,31 @@ import (
|
||||
)
|
||||
|
||||
const createCoverArt = `-- name: CreateCoverArt :one
|
||||
INSERT INTO cover_art (is_embedded, file_path, file_type_id) VALUES (?, ?, ?)
|
||||
RETURNING id, is_embedded, file_path, file_type_id
|
||||
INSERT INTO cover_art (is_embedded, file_path, mime_type) VALUES (?, ?, ?)
|
||||
RETURNING id, is_embedded, file_path, mime_type
|
||||
`
|
||||
|
||||
type CreateCoverArtParams struct {
|
||||
IsEmbedded bool
|
||||
FilePath string
|
||||
FileTypeID int64
|
||||
MimeType string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateCoverArt(ctx context.Context, arg CreateCoverArtParams) (CoverArt, error) {
|
||||
row := q.db.QueryRowContext(ctx, createCoverArt, arg.IsEmbedded, arg.FilePath, arg.FileTypeID)
|
||||
row := q.db.QueryRowContext(ctx, createCoverArt, arg.IsEmbedded, arg.FilePath, arg.MimeType)
|
||||
var i CoverArt
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.IsEmbedded,
|
||||
&i.FilePath,
|
||||
&i.FileTypeID,
|
||||
&i.MimeType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteCoverArt = `-- name: DeleteCoverArt :exec
|
||||
DELETE FROM cover_art
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteCoverArt(ctx context.Context, id int64) error {
|
||||
@@ -43,7 +43,7 @@ func (q *Queries) DeleteCoverArt(ctx context.Context, id int64) error {
|
||||
}
|
||||
|
||||
const getCoverArt = `-- name: GetCoverArt :one
|
||||
SELECT id, is_embedded, file_path, file_type_id FROM cover_art
|
||||
SELECT id, is_embedded, file_path, mime_type FROM cover_art
|
||||
WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
@@ -54,21 +54,38 @@ func (q *Queries) GetCoverArt(ctx context.Context, id int64) (CoverArt, error) {
|
||||
&i.ID,
|
||||
&i.IsEmbedded,
|
||||
&i.FilePath,
|
||||
&i.FileTypeID,
|
||||
&i.MimeType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getCoverArtByPath = `-- name: GetCoverArtByPath :one
|
||||
SELECT id, is_embedded, file_path, mime_type FROM cover_art
|
||||
WHERE file_path = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetCoverArtByPath(ctx context.Context, filePath string) (CoverArt, error) {
|
||||
row := q.db.QueryRowContext(ctx, getCoverArtByPath, filePath)
|
||||
var i CoverArt
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.IsEmbedded,
|
||||
&i.FilePath,
|
||||
&i.MimeType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateCoverArt = `-- name: UpdateCoverArt :exec
|
||||
UPDATE cover_art
|
||||
SET is_embedded = ?, file_path = ?, file_type_id = ?
|
||||
WHERE id =?
|
||||
SET is_embedded = ?, file_path = ?, mime_type = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateCoverArtParams struct {
|
||||
IsEmbedded bool
|
||||
FilePath string
|
||||
FileTypeID int64
|
||||
MimeType string
|
||||
ID int64
|
||||
}
|
||||
|
||||
@@ -76,8 +93,35 @@ func (q *Queries) UpdateCoverArt(ctx context.Context, arg UpdateCoverArtParams)
|
||||
_, err := q.db.ExecContext(ctx, updateCoverArt,
|
||||
arg.IsEmbedded,
|
||||
arg.FilePath,
|
||||
arg.FileTypeID,
|
||||
arg.MimeType,
|
||||
arg.ID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertCoverArt = `-- name: UpsertCoverArt :one
|
||||
INSERT INTO cover_art (is_embedded, file_path, mime_type)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(file_path) DO UPDATE SET
|
||||
is_embedded = excluded.is_embedded,
|
||||
mime_type = excluded.mime_type
|
||||
RETURNING id, is_embedded, file_path, mime_type
|
||||
`
|
||||
|
||||
type UpsertCoverArtParams struct {
|
||||
IsEmbedded bool
|
||||
FilePath string
|
||||
MimeType string
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertCoverArt(ctx context.Context, arg UpsertCoverArtParams) (CoverArt, error) {
|
||||
row := q.db.QueryRowContext(ctx, upsertCoverArt, arg.IsEmbedded, arg.FilePath, arg.MimeType)
|
||||
var i CoverArt
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.IsEmbedded,
|
||||
&i.FilePath,
|
||||
&i.MimeType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
|
||||
package sqlcgen
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: file_types.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Artist struct {
|
||||
ID int64
|
||||
Name string
|
||||
@@ -11,7 +16,7 @@ type Artist struct {
|
||||
|
||||
type ArtistCredit struct {
|
||||
ID int64
|
||||
Text interface{}
|
||||
Text string
|
||||
}
|
||||
|
||||
type ArtistCreditArtist struct {
|
||||
@@ -32,7 +37,7 @@ type CoverArt struct {
|
||||
ID int64
|
||||
IsEmbedded bool
|
||||
FilePath string
|
||||
FileTypeID int64
|
||||
MimeType string
|
||||
}
|
||||
|
||||
type FileType struct {
|
||||
@@ -40,20 +45,70 @@ type FileType struct {
|
||||
Extension string
|
||||
}
|
||||
|
||||
type PlayerState struct {
|
||||
ID int64
|
||||
Volume int64
|
||||
Muted bool
|
||||
LastTrackPath string
|
||||
LastPositionSeconds int64
|
||||
}
|
||||
|
||||
type Playlist struct {
|
||||
ID int64
|
||||
Name string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type PlaylistTrack struct {
|
||||
ID int64
|
||||
PlaylistID int64
|
||||
AudioFileID int64
|
||||
Position int64
|
||||
}
|
||||
|
||||
type Queue struct {
|
||||
ID int64
|
||||
SourcePlaylistID sql.NullInt64
|
||||
CurrentPosition int64
|
||||
ShuffleMode bool
|
||||
RepeatMode string
|
||||
ShuffleOrder sql.NullString
|
||||
}
|
||||
|
||||
type QueueTrack struct {
|
||||
ID int64
|
||||
AudioFileID int64
|
||||
Position int64
|
||||
}
|
||||
|
||||
type Recording struct {
|
||||
ID int64
|
||||
Name string
|
||||
ArtistCreditID int64
|
||||
TrackNumber sql.NullInt64
|
||||
DiscNumber sql.NullInt64
|
||||
Year sql.NullInt64
|
||||
Genre sql.NullString
|
||||
Composer sql.NullString
|
||||
Lyrics sql.NullString
|
||||
Comment sql.NullString
|
||||
}
|
||||
|
||||
type ReleaseGroup struct {
|
||||
ID int64
|
||||
Name string
|
||||
CoverArtID int64
|
||||
ID int64
|
||||
Name string
|
||||
CoverArtID sql.NullInt64
|
||||
AlbumArtistCreditID sql.NullInt64
|
||||
Year sql.NullInt64
|
||||
TotalTracks sql.NullInt64
|
||||
TotalDiscs sql.NullInt64
|
||||
}
|
||||
|
||||
type ReleaseGroupRecording struct {
|
||||
ID int64
|
||||
ReleaseGroupID int64
|
||||
RecordingID int64
|
||||
TrackNumber sql.NullInt64
|
||||
DiscNumber sql.NullInt64
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// source: player_state.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getPlayerState = `-- name: GetPlayerState :one
|
||||
SELECT volume, muted, last_track_path, last_position_seconds
|
||||
FROM player_state WHERE id = 1
|
||||
`
|
||||
|
||||
type GetPlayerStateRow struct {
|
||||
Volume int64
|
||||
Muted bool
|
||||
LastTrackPath string
|
||||
LastPositionSeconds int64
|
||||
}
|
||||
|
||||
func (q *Queries) GetPlayerState(ctx context.Context) (GetPlayerStateRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getPlayerState)
|
||||
var i GetPlayerStateRow
|
||||
err := row.Scan(
|
||||
&i.Volume,
|
||||
&i.Muted,
|
||||
&i.LastTrackPath,
|
||||
&i.LastPositionSeconds,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updatePlayerState = `-- name: UpdatePlayerState :exec
|
||||
UPDATE player_state
|
||||
SET volume = ?, muted = ?, last_track_path = ?, last_position_seconds = ?
|
||||
WHERE id = 1
|
||||
`
|
||||
|
||||
type UpdatePlayerStateParams struct {
|
||||
Volume int64
|
||||
Muted bool
|
||||
LastTrackPath string
|
||||
LastPositionSeconds int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdatePlayerState(ctx context.Context, arg UpdatePlayerStateParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updatePlayerState,
|
||||
arg.Volume,
|
||||
arg.Muted,
|
||||
arg.LastTrackPath,
|
||||
arg.LastPositionSeconds,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// source: playlists.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const addPlaylistTrack = `-- name: AddPlaylistTrack :one
|
||||
INSERT INTO playlist_tracks (playlist_id, audio_file_id, position) VALUES (?, ?, ?)
|
||||
RETURNING id, playlist_id, audio_file_id, position
|
||||
`
|
||||
|
||||
type AddPlaylistTrackParams struct {
|
||||
PlaylistID int64
|
||||
AudioFileID int64
|
||||
Position int64
|
||||
}
|
||||
|
||||
func (q *Queries) AddPlaylistTrack(ctx context.Context, arg AddPlaylistTrackParams) (PlaylistTrack, error) {
|
||||
row := q.db.QueryRowContext(ctx, addPlaylistTrack, arg.PlaylistID, arg.AudioFileID, arg.Position)
|
||||
var i PlaylistTrack
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.PlaylistID,
|
||||
&i.AudioFileID,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const clearPlaylistTracks = `-- name: ClearPlaylistTracks :exec
|
||||
DELETE FROM playlist_tracks WHERE playlist_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) ClearPlaylistTracks(ctx context.Context, playlistID int64) error {
|
||||
_, err := q.db.ExecContext(ctx, clearPlaylistTracks, playlistID)
|
||||
return err
|
||||
}
|
||||
|
||||
const createPlaylist = `-- name: CreatePlaylist :one
|
||||
INSERT INTO playlists (name) VALUES (?)
|
||||
RETURNING id, name, created_at, updated_at
|
||||
`
|
||||
|
||||
func (q *Queries) CreatePlaylist(ctx context.Context, name string) (Playlist, error) {
|
||||
row := q.db.QueryRowContext(ctx, createPlaylist, name)
|
||||
var i Playlist
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deletePlaylist = `-- name: DeletePlaylist :exec
|
||||
DELETE FROM playlists WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeletePlaylist(ctx context.Context, id int64) error {
|
||||
_, err := q.db.ExecContext(ctx, deletePlaylist, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllPlaylists = `-- name: GetAllPlaylists :many
|
||||
SELECT id, name, created_at, updated_at FROM playlists ORDER BY updated_at DESC
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllPlaylists(ctx context.Context) ([]Playlist, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllPlaylists)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Playlist
|
||||
for rows.Next() {
|
||||
var i Playlist
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); 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 getPlaylist = `-- name: GetPlaylist :one
|
||||
SELECT id, name, created_at, updated_at FROM playlists WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetPlaylist(ctx context.Context, id int64) (Playlist, error) {
|
||||
row := q.db.QueryRowContext(ctx, getPlaylist, id)
|
||||
var i Playlist
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getPlaylistTracks = `-- name: GetPlaylistTracks :many
|
||||
SELECT pt.id, pt.playlist_id, pt.audio_file_id, pt.position, af.file_path
|
||||
FROM playlist_tracks pt
|
||||
JOIN audio_files af ON pt.audio_file_id = af.id
|
||||
WHERE pt.playlist_id = ?
|
||||
ORDER BY pt.position
|
||||
`
|
||||
|
||||
type GetPlaylistTracksRow struct {
|
||||
ID int64
|
||||
PlaylistID int64
|
||||
AudioFileID int64
|
||||
Position int64
|
||||
FilePath string
|
||||
}
|
||||
|
||||
func (q *Queries) GetPlaylistTracks(ctx context.Context, playlistID int64) ([]GetPlaylistTracksRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getPlaylistTracks, playlistID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetPlaylistTracksRow
|
||||
for rows.Next() {
|
||||
var i GetPlaylistTracksRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.PlaylistID,
|
||||
&i.AudioFileID,
|
||||
&i.Position,
|
||||
&i.FilePath,
|
||||
); 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 removePlaylistTrack = `-- name: RemovePlaylistTrack :exec
|
||||
DELETE FROM playlist_tracks WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) RemovePlaylistTrack(ctx context.Context, id int64) error {
|
||||
_, err := q.db.ExecContext(ctx, removePlaylistTrack, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const updatePlaylistName = `-- name: UpdatePlaylistName :exec
|
||||
UPDATE playlists SET name = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdatePlaylistNameParams struct {
|
||||
Name string
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdatePlaylistName(ctx context.Context, arg UpdatePlaylistNameParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updatePlaylistName, arg.Name, arg.ID)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// source: queue.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const clearQueueTracks = `-- name: ClearQueueTracks :exec
|
||||
DELETE FROM queue_tracks
|
||||
`
|
||||
|
||||
func (q *Queries) ClearQueueTracks(ctx context.Context) error {
|
||||
_, err := q.db.ExecContext(ctx, clearQueueTracks)
|
||||
return err
|
||||
}
|
||||
|
||||
const getQueueState = `-- name: GetQueueState :one
|
||||
SELECT source_playlist_id, current_position, shuffle_mode, repeat_mode, shuffle_order
|
||||
FROM queue WHERE id = 1
|
||||
`
|
||||
|
||||
type GetQueueStateRow struct {
|
||||
SourcePlaylistID sql.NullInt64
|
||||
CurrentPosition int64
|
||||
ShuffleMode bool
|
||||
RepeatMode string
|
||||
ShuffleOrder sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) GetQueueState(ctx context.Context) (GetQueueStateRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getQueueState)
|
||||
var i GetQueueStateRow
|
||||
err := row.Scan(
|
||||
&i.SourcePlaylistID,
|
||||
&i.CurrentPosition,
|
||||
&i.ShuffleMode,
|
||||
&i.RepeatMode,
|
||||
&i.ShuffleOrder,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getQueueTrackCount = `-- name: GetQueueTrackCount :one
|
||||
SELECT count(*) FROM queue_tracks
|
||||
`
|
||||
|
||||
func (q *Queries) GetQueueTrackCount(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, getQueueTrackCount)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const getQueueTracks = `-- name: GetQueueTracks :many
|
||||
SELECT qt.id, qt.audio_file_id, qt.position, af.file_path,
|
||||
COALESCE(r.name, '') AS title,
|
||||
COALESCE(ac.text, '') AS artist
|
||||
FROM queue_tracks qt
|
||||
JOIN audio_files af ON qt.audio_file_id = af.id
|
||||
LEFT JOIN recordings r ON af.recording_id = r.id
|
||||
LEFT JOIN artist_credit ac ON r.artist_credit_id = ac.id
|
||||
ORDER BY qt.position
|
||||
`
|
||||
|
||||
type GetQueueTracksRow struct {
|
||||
ID int64
|
||||
AudioFileID int64
|
||||
Position int64
|
||||
FilePath string
|
||||
Title string
|
||||
Artist string
|
||||
}
|
||||
|
||||
func (q *Queries) GetQueueTracks(ctx context.Context) ([]GetQueueTracksRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getQueueTracks)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetQueueTracksRow
|
||||
for rows.Next() {
|
||||
var i GetQueueTracksRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.AudioFileID,
|
||||
&i.Position,
|
||||
&i.FilePath,
|
||||
&i.Title,
|
||||
&i.Artist,
|
||||
); 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 insertQueueTrack = `-- name: InsertQueueTrack :one
|
||||
INSERT INTO queue_tracks (audio_file_id, position) VALUES (?, ?)
|
||||
RETURNING id, audio_file_id, position
|
||||
`
|
||||
|
||||
type InsertQueueTrackParams struct {
|
||||
AudioFileID int64
|
||||
Position int64
|
||||
}
|
||||
|
||||
func (q *Queries) InsertQueueTrack(ctx context.Context, arg InsertQueueTrackParams) (QueueTrack, error) {
|
||||
row := q.db.QueryRowContext(ctx, insertQueueTrack, arg.AudioFileID, arg.Position)
|
||||
var i QueueTrack
|
||||
err := row.Scan(&i.ID, &i.AudioFileID, &i.Position)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const removeQueueTrack = `-- name: RemoveQueueTrack :exec
|
||||
DELETE FROM queue_tracks WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) RemoveQueueTrack(ctx context.Context, id int64) error {
|
||||
_, err := q.db.ExecContext(ctx, removeQueueTrack, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const removeQueueTrackByPosition = `-- name: RemoveQueueTrackByPosition :exec
|
||||
DELETE FROM queue_tracks WHERE position = ?
|
||||
`
|
||||
|
||||
func (q *Queries) RemoveQueueTrackByPosition(ctx context.Context, position int64) error {
|
||||
_, err := q.db.ExecContext(ctx, removeQueueTrackByPosition, position)
|
||||
return err
|
||||
}
|
||||
|
||||
const shiftQueuePositionsDown = `-- name: ShiftQueuePositionsDown :exec
|
||||
UPDATE queue_tracks
|
||||
SET position = position - 1
|
||||
WHERE position > ?
|
||||
`
|
||||
|
||||
func (q *Queries) ShiftQueuePositionsDown(ctx context.Context, position int64) error {
|
||||
_, err := q.db.ExecContext(ctx, shiftQueuePositionsDown, position)
|
||||
return err
|
||||
}
|
||||
|
||||
const shiftQueuePositionsUp = `-- name: ShiftQueuePositionsUp :exec
|
||||
UPDATE queue_tracks
|
||||
SET position = position + 1
|
||||
WHERE position >= ?
|
||||
`
|
||||
|
||||
func (q *Queries) ShiftQueuePositionsUp(ctx context.Context, position int64) error {
|
||||
_, err := q.db.ExecContext(ctx, shiftQueuePositionsUp, position)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateQueuePosition = `-- name: UpdateQueuePosition :exec
|
||||
UPDATE queue
|
||||
SET current_position = ?
|
||||
WHERE id = 1
|
||||
`
|
||||
|
||||
func (q *Queries) UpdateQueuePosition(ctx context.Context, currentPosition int64) error {
|
||||
_, err := q.db.ExecContext(ctx, updateQueuePosition, currentPosition)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateQueueState = `-- name: UpdateQueueState :exec
|
||||
UPDATE queue
|
||||
SET source_playlist_id = ?, current_position = ?, shuffle_mode = ?, repeat_mode = ?, shuffle_order = ?
|
||||
WHERE id = 1
|
||||
`
|
||||
|
||||
type UpdateQueueStateParams struct {
|
||||
SourcePlaylistID sql.NullInt64
|
||||
CurrentPosition int64
|
||||
ShuffleMode bool
|
||||
RepeatMode string
|
||||
ShuffleOrder sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateQueueState(ctx context.Context, arg UpdateQueueStateParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateQueueState,
|
||||
arg.SourcePlaylistID,
|
||||
arg.CurrentPosition,
|
||||
arg.ShuffleMode,
|
||||
arg.RepeatMode,
|
||||
arg.ShuffleOrder,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -1,29 +1,94 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: recordings.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createRecording = `-- name: CreateRecording :one
|
||||
INSERT INTO recordings (name) VALUES (?)
|
||||
RETURNING id, name, artist_credit_id
|
||||
INSERT INTO recordings (name, artist_credit_id) VALUES (?, ?)
|
||||
RETURNING id, name, artist_credit_id, track_number, disc_number, year, genre, composer, lyrics, comment
|
||||
`
|
||||
|
||||
func (q *Queries) CreateRecording(ctx context.Context, name string) (Recording, error) {
|
||||
row := q.db.QueryRowContext(ctx, createRecording, name)
|
||||
type CreateRecordingParams struct {
|
||||
Name string
|
||||
ArtistCreditID int64
|
||||
}
|
||||
|
||||
func (q *Queries) CreateRecording(ctx context.Context, arg CreateRecordingParams) (Recording, error) {
|
||||
row := q.db.QueryRowContext(ctx, createRecording, arg.Name, arg.ArtistCreditID)
|
||||
var i Recording
|
||||
err := row.Scan(&i.ID, &i.Name, &i.ArtistCreditID)
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.ArtistCreditID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
&i.Year,
|
||||
&i.Genre,
|
||||
&i.Composer,
|
||||
&i.Lyrics,
|
||||
&i.Comment,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createRecordingFull = `-- name: CreateRecordingFull :one
|
||||
INSERT INTO recordings (
|
||||
name, artist_credit_id, track_number, disc_number,
|
||||
year, genre, composer, lyrics, comment
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING id, name, artist_credit_id, track_number, disc_number, year, genre, composer, lyrics, comment
|
||||
`
|
||||
|
||||
type CreateRecordingFullParams struct {
|
||||
Name string
|
||||
ArtistCreditID int64
|
||||
TrackNumber sql.NullInt64
|
||||
DiscNumber sql.NullInt64
|
||||
Year sql.NullInt64
|
||||
Genre sql.NullString
|
||||
Composer sql.NullString
|
||||
Lyrics sql.NullString
|
||||
Comment sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) CreateRecordingFull(ctx context.Context, arg CreateRecordingFullParams) (Recording, error) {
|
||||
row := q.db.QueryRowContext(ctx, createRecordingFull,
|
||||
arg.Name,
|
||||
arg.ArtistCreditID,
|
||||
arg.TrackNumber,
|
||||
arg.DiscNumber,
|
||||
arg.Year,
|
||||
arg.Genre,
|
||||
arg.Composer,
|
||||
arg.Lyrics,
|
||||
arg.Comment,
|
||||
)
|
||||
var i Recording
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.ArtistCreditID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
&i.Year,
|
||||
&i.Genre,
|
||||
&i.Composer,
|
||||
&i.Lyrics,
|
||||
&i.Comment,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteRecording = `-- name: DeleteRecording :exec
|
||||
DELETE FROM recordings
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteRecording(ctx context.Context, id int64) error {
|
||||
@@ -31,30 +96,117 @@ func (q *Queries) DeleteRecording(ctx context.Context, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllRecordings = `-- name: GetAllRecordings :many
|
||||
SELECT id, name, artist_credit_id, track_number, disc_number, year, genre, composer, lyrics, comment FROM recordings
|
||||
ORDER BY name
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllRecordings(ctx context.Context) ([]Recording, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllRecordings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Recording
|
||||
for rows.Next() {
|
||||
var i Recording
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.ArtistCreditID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
&i.Year,
|
||||
&i.Genre,
|
||||
&i.Composer,
|
||||
&i.Lyrics,
|
||||
&i.Comment,
|
||||
); 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 getRecording = `-- name: GetRecording :one
|
||||
SELECT id, name, artist_credit_id FROM recordings
|
||||
SELECT id, name, artist_credit_id, track_number, disc_number, year, genre, composer, lyrics, comment FROM recordings
|
||||
WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetRecording(ctx context.Context, id int64) (Recording, error) {
|
||||
row := q.db.QueryRowContext(ctx, getRecording, id)
|
||||
var i Recording
|
||||
err := row.Scan(&i.ID, &i.Name, &i.ArtistCreditID)
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.ArtistCreditID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
&i.Year,
|
||||
&i.Genre,
|
||||
&i.Composer,
|
||||
&i.Lyrics,
|
||||
&i.Comment,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateRecording = `-- name: UpdateRecording :exec
|
||||
UPDATE recordings
|
||||
SET name = ?
|
||||
WHERE id =?
|
||||
SET name = ?, artist_credit_id = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateRecordingParams struct {
|
||||
Name string
|
||||
ID int64
|
||||
Name string
|
||||
ArtistCreditID int64
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateRecording(ctx context.Context, arg UpdateRecordingParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateRecording, arg.Name, arg.ID)
|
||||
_, err := q.db.ExecContext(ctx, updateRecording, arg.Name, arg.ArtistCreditID, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateRecordingFull = `-- name: UpdateRecordingFull :exec
|
||||
UPDATE recordings
|
||||
SET name = ?, artist_credit_id = ?, track_number = ?, disc_number = ?,
|
||||
year = ?, genre = ?, composer = ?, lyrics = ?, comment = ?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
type UpdateRecordingFullParams struct {
|
||||
Name string
|
||||
ArtistCreditID int64
|
||||
TrackNumber sql.NullInt64
|
||||
DiscNumber sql.NullInt64
|
||||
Year sql.NullInt64
|
||||
Genre sql.NullString
|
||||
Composer sql.NullString
|
||||
Lyrics sql.NullString
|
||||
Comment sql.NullString
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateRecordingFull(ctx context.Context, arg UpdateRecordingFullParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateRecordingFull,
|
||||
arg.Name,
|
||||
arg.ArtistCreditID,
|
||||
arg.TrackNumber,
|
||||
arg.DiscNumber,
|
||||
arg.Year,
|
||||
arg.Genre,
|
||||
arg.Composer,
|
||||
arg.Lyrics,
|
||||
arg.Comment,
|
||||
arg.ID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,34 +1,49 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.28.0
|
||||
// sqlc v1.29.0
|
||||
// source: release_group_recordings.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createReleaseGroupRecording = `-- name: CreateReleaseGroupRecording :one
|
||||
INSERT INTO release_group_recordings (release_group_id, recording_id) VALUES (?,?)
|
||||
RETURNING id, release_group_id, recording_id
|
||||
INSERT INTO release_group_recordings (release_group_id, recording_id, track_number, disc_number)
|
||||
VALUES (?, ?, ?, ?)
|
||||
RETURNING id, release_group_id, recording_id, track_number, disc_number
|
||||
`
|
||||
|
||||
type CreateReleaseGroupRecordingParams struct {
|
||||
ReleaseGroupID int64
|
||||
RecordingID int64
|
||||
TrackNumber sql.NullInt64
|
||||
DiscNumber sql.NullInt64
|
||||
}
|
||||
|
||||
func (q *Queries) CreateReleaseGroupRecording(ctx context.Context, arg CreateReleaseGroupRecordingParams) (ReleaseGroupRecording, error) {
|
||||
row := q.db.QueryRowContext(ctx, createReleaseGroupRecording, arg.ReleaseGroupID, arg.RecordingID)
|
||||
row := q.db.QueryRowContext(ctx, createReleaseGroupRecording,
|
||||
arg.ReleaseGroupID,
|
||||
arg.RecordingID,
|
||||
arg.TrackNumber,
|
||||
arg.DiscNumber,
|
||||
)
|
||||
var i ReleaseGroupRecording
|
||||
err := row.Scan(&i.ID, &i.ReleaseGroupID, &i.RecordingID)
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.ReleaseGroupID,
|
||||
&i.RecordingID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteReleaseGroupRecording = `-- name: DeleteReleaseGroupRecording :exec
|
||||
DELETE FROM release_group_recordings
|
||||
WHERE id =?
|
||||
WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteReleaseGroupRecording(ctx context.Context, id int64) error {
|
||||
@@ -36,31 +51,104 @@ func (q *Queries) DeleteReleaseGroupRecording(ctx context.Context, id int64) err
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteReleaseGroupRecordingByFK = `-- name: DeleteReleaseGroupRecordingByFK :exec
|
||||
DELETE FROM release_group_recordings
|
||||
WHERE release_group_id = ? AND recording_id = ?
|
||||
`
|
||||
|
||||
type DeleteReleaseGroupRecordingByFKParams struct {
|
||||
ReleaseGroupID int64
|
||||
RecordingID int64
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteReleaseGroupRecordingByFK(ctx context.Context, arg DeleteReleaseGroupRecordingByFKParams) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteReleaseGroupRecordingByFK, arg.ReleaseGroupID, arg.RecordingID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getRecordingReleaseGroups = `-- name: GetRecordingReleaseGroups :many
|
||||
SELECT id, release_group_id, recording_id, track_number, disc_number FROM release_group_recordings
|
||||
WHERE recording_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) GetRecordingReleaseGroups(ctx context.Context, recordingID int64) ([]ReleaseGroupRecording, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getRecordingReleaseGroups, recordingID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ReleaseGroupRecording
|
||||
for rows.Next() {
|
||||
var i ReleaseGroupRecording
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.ReleaseGroupID,
|
||||
&i.RecordingID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
); 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 getReleaseGroupRecording = `-- name: GetReleaseGroupRecording :one
|
||||
SELECT id, release_group_id, recording_id FROM release_group_recordings
|
||||
SELECT id, release_group_id, recording_id, track_number, disc_number FROM release_group_recordings
|
||||
WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetReleaseGroupRecording(ctx context.Context, id int64) (ReleaseGroupRecording, error) {
|
||||
row := q.db.QueryRowContext(ctx, getReleaseGroupRecording, id)
|
||||
var i ReleaseGroupRecording
|
||||
err := row.Scan(&i.ID, &i.ReleaseGroupID, &i.RecordingID)
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.ReleaseGroupID,
|
||||
&i.RecordingID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateReleaseGroupRecording = `-- name: UpdateReleaseGroupRecording :exec
|
||||
UPDATE release_group_recordings
|
||||
SET release_group_id = ?, recording_id = ?
|
||||
WHERE id =?
|
||||
const getReleaseGroupRecordings = `-- name: GetReleaseGroupRecordings :many
|
||||
SELECT id, release_group_id, recording_id, track_number, disc_number FROM release_group_recordings
|
||||
WHERE release_group_id = ?
|
||||
ORDER BY disc_number, track_number
|
||||
`
|
||||
|
||||
type UpdateReleaseGroupRecordingParams struct {
|
||||
ReleaseGroupID int64
|
||||
RecordingID int64
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateReleaseGroupRecording(ctx context.Context, arg UpdateReleaseGroupRecordingParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateReleaseGroupRecording, arg.ReleaseGroupID, arg.RecordingID, arg.ID)
|
||||
return err
|
||||
func (q *Queries) GetReleaseGroupRecordings(ctx context.Context, releaseGroupID int64) ([]ReleaseGroupRecording, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getReleaseGroupRecordings, releaseGroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ReleaseGroupRecording
|
||||
for rows.Next() {
|
||||
var i ReleaseGroupRecording
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.ReleaseGroupID,
|
||||
&i.RecordingID,
|
||||
&i.TrackNumber,
|
||||
&i.DiscNumber,
|
||||
); 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
|
||||
}
|
||||
|
||||
@@ -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