* chore(deps): update go dependencies (non-major) * fix: regenerate code and add postUpgradeTasks for Renovate Regenerate templ and sqlc output to match bumped tool versions. Configure Renovate postUpgradeTasks to run 'go generate ./...' after Go dependency updates, preventing stale generated files in future PRs. --------- Co-authored-by: onion-4-dinner <15676555+onion-4-dinner@users.noreply.github.com>
400 lines
9.5 KiB
Go
400 lines
9.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.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
|
|
`
|
|
|
|
type CreateAudioFileParams struct {
|
|
FilePath string
|
|
LengthMilliseconds int64
|
|
FileTypeID int64
|
|
RecordingID int64
|
|
}
|
|
|
|
func (q *Queries) CreateAudioFile(ctx context.Context, arg CreateAudioFileParams) (AudioFile, error) {
|
|
row := q.db.QueryRowContext(ctx, createAudioFile,
|
|
arg.FilePath,
|
|
arg.LengthMilliseconds,
|
|
arg.FileTypeID,
|
|
arg.RecordingID,
|
|
)
|
|
var i AudioFile
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.FilePath,
|
|
&i.LengthMilliseconds,
|
|
&i.FileTypeID,
|
|
&i.RecordingID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteAudioFile = `-- name: DeleteAudioFile :exec
|
|
DELETE FROM audio_files
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteAudioFile(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteAudioFile, id)
|
|
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
|
|
`
|
|
|
|
func (q *Queries) GetAudioFile(ctx context.Context, id int64) (AudioFile, error) {
|
|
row := q.db.QueryRowContext(ctx, getAudioFile, id)
|
|
var i AudioFile
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.FilePath,
|
|
&i.LengthMilliseconds,
|
|
&i.FileTypeID,
|
|
&i.RecordingID,
|
|
)
|
|
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 = ?
|
|
`
|
|
|
|
type UpdateAudioFileParams struct {
|
|
FilePath string
|
|
LengthMilliseconds int64
|
|
FileTypeID int64
|
|
RecordingID int64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateAudioFile(ctx context.Context, arg UpdateAudioFileParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateAudioFile,
|
|
arg.FilePath,
|
|
arg.LengthMilliseconds,
|
|
arg.FileTypeID,
|
|
arg.RecordingID,
|
|
arg.ID,
|
|
)
|
|
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
|
|
}
|