The GetAudioFilesByReleaseGroup SQL query only selected 6 columns, missing audio properties (sample_rate, bit_depth, channels, bitrate, file_size) and metadata (album, genre, year, composer, file_type). This caused track details opened from the album view to show dashes instead of actual values. Expanded the query to match GetAllTracksWithFullMetadata and updated GetAlbumTracks to use the shared mapTrackRow helper.
722 lines
18 KiB
Go
722 lines
18 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: audio_files.sql
|
|
|
|
package sqlcgen
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"strings"
|
|
)
|
|
|
|
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, sample_rate, bit_depth, channels, bitrate, file_size, basename) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
RETURNING id, file_path, length_milliseconds, file_type_id, recording_id, sample_rate, bit_depth, channels, bitrate, file_size, basename
|
|
`
|
|
|
|
type CreateAudioFileParams struct {
|
|
FilePath string
|
|
LengthMilliseconds int64
|
|
FileTypeID int64
|
|
RecordingID int64
|
|
SampleRate int64
|
|
BitDepth int64
|
|
Channels int64
|
|
Bitrate int64
|
|
FileSize int64
|
|
Basename string
|
|
}
|
|
|
|
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,
|
|
arg.SampleRate,
|
|
arg.BitDepth,
|
|
arg.Channels,
|
|
arg.Bitrate,
|
|
arg.FileSize,
|
|
arg.Basename,
|
|
)
|
|
var i AudioFile
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.FilePath,
|
|
&i.LengthMilliseconds,
|
|
&i.FileTypeID,
|
|
&i.RecordingID,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
&i.Basename,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteAllAudioFiles = `-- name: DeleteAllAudioFiles :exec
|
|
DELETE FROM audio_files
|
|
`
|
|
|
|
func (q *Queries) DeleteAllAudioFiles(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, deleteAllAudioFiles)
|
|
return 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, sample_rate, bit_depth, channels, bitrate, file_size, basename 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,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
&i.Basename,
|
|
); 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 getAllTracksWithFullMetadata = `-- name: GetAllTracksWithFullMetadata :many
|
|
SELECT
|
|
af.file_path,
|
|
af.length_milliseconds,
|
|
COALESCE(r.name, '') AS title,
|
|
COALESCE(ac.text, '') AS artist_name,
|
|
r.track_number,
|
|
r.disc_number,
|
|
COALESCE(rg.name, '') AS album,
|
|
CAST(COALESCE(
|
|
(SELECT GROUP_CONCAT(g.name, '||')
|
|
FROM recording_genres rg_sub
|
|
JOIN genres g ON rg_sub.genre_id = g.id
|
|
WHERE rg_sub.recording_id = r.id),
|
|
''
|
|
) AS TEXT) AS genre,
|
|
COALESCE(r.year, 0) AS year,
|
|
COALESCE(r.composer, '') AS composer,
|
|
COALESCE(ft.extension, '') AS file_type,
|
|
af.sample_rate,
|
|
af.bit_depth,
|
|
af.channels,
|
|
af.bitrate,
|
|
af.file_size
|
|
FROM audio_files af
|
|
JOIN recordings r ON af.recording_id = r.id
|
|
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 file_types ft ON af.file_type_id = ft.id
|
|
`
|
|
|
|
type GetAllTracksWithFullMetadataRow struct {
|
|
FilePath string
|
|
LengthMilliseconds int64
|
|
Title string
|
|
ArtistName string
|
|
TrackNumber sql.NullInt64
|
|
DiscNumber sql.NullInt64
|
|
Album string
|
|
Genre string
|
|
Year int64
|
|
Composer string
|
|
FileType string
|
|
SampleRate int64
|
|
BitDepth int64
|
|
Channels int64
|
|
Bitrate int64
|
|
FileSize int64
|
|
}
|
|
|
|
func (q *Queries) GetAllTracksWithFullMetadata(ctx context.Context) ([]GetAllTracksWithFullMetadataRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getAllTracksWithFullMetadata)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetAllTracksWithFullMetadataRow
|
|
for rows.Next() {
|
|
var i GetAllTracksWithFullMetadataRow
|
|
if err := rows.Scan(
|
|
&i.FilePath,
|
|
&i.LengthMilliseconds,
|
|
&i.Title,
|
|
&i.ArtistName,
|
|
&i.TrackNumber,
|
|
&i.DiscNumber,
|
|
&i.Album,
|
|
&i.Genre,
|
|
&i.Year,
|
|
&i.Composer,
|
|
&i.FileType,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
); 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, sample_rate, bit_depth, channels, bitrate, file_size, basename 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,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
&i.Basename,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getAudioFileByPath = `-- name: GetAudioFileByPath :one
|
|
SELECT id, file_path, length_milliseconds, file_type_id, recording_id, sample_rate, bit_depth, channels, bitrate, file_size, basename 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,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
&i.Basename,
|
|
)
|
|
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,
|
|
COALESCE(rg.name, '') AS album,
|
|
CAST(COALESCE(
|
|
(SELECT GROUP_CONCAT(g.name, '||')
|
|
FROM recording_genres rg_sub
|
|
JOIN genres g ON rg_sub.genre_id = g.id
|
|
WHERE rg_sub.recording_id = r.id),
|
|
''
|
|
) AS TEXT) AS genre,
|
|
COALESCE(r.year, 0) AS year,
|
|
COALESCE(r.composer, '') AS composer,
|
|
COALESCE(ft.extension, '') AS file_type,
|
|
af.sample_rate,
|
|
af.bit_depth,
|
|
af.channels,
|
|
af.bitrate,
|
|
af.file_size
|
|
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
|
|
LEFT JOIN release_groups rg ON rgr.release_group_id = rg.id
|
|
LEFT JOIN file_types ft ON af.file_type_id = ft.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
|
|
Album string
|
|
Genre string
|
|
Year int64
|
|
Composer string
|
|
FileType string
|
|
SampleRate int64
|
|
BitDepth int64
|
|
Channels int64
|
|
Bitrate int64
|
|
FileSize int64
|
|
}
|
|
|
|
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,
|
|
&i.Album,
|
|
&i.Genre,
|
|
&i.Year,
|
|
&i.Composer,
|
|
&i.FileType,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
); 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, sample_rate, bit_depth, channels, bitrate, file_size, basename 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,
|
|
&i.SampleRate,
|
|
&i.BitDepth,
|
|
&i.Channels,
|
|
&i.Bitrate,
|
|
&i.FileSize,
|
|
&i.Basename,
|
|
); 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,
|
|
af.length_milliseconds,
|
|
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
|
|
LengthMilliseconds int64
|
|
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.LengthMilliseconds,
|
|
&i.Title,
|
|
&i.Artist,
|
|
&i.Album,
|
|
&i.CoverArtPath,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const lookupTrackMetaByPaths = `-- name: LookupTrackMetaByPaths :many
|
|
SELECT id, file_path, title, artist_name
|
|
FROM track_metadata
|
|
WHERE file_path IN (/*SLICE:paths*/?)
|
|
`
|
|
|
|
type LookupTrackMetaByPathsRow struct {
|
|
ID int64
|
|
FilePath string
|
|
Title string
|
|
ArtistName string
|
|
}
|
|
|
|
func (q *Queries) LookupTrackMetaByPaths(ctx context.Context, paths []string) ([]LookupTrackMetaByPathsRow, error) {
|
|
query := lookupTrackMetaByPaths
|
|
var queryParams []interface{}
|
|
if len(paths) > 0 {
|
|
for _, v := range paths {
|
|
queryParams = append(queryParams, v)
|
|
}
|
|
query = strings.Replace(query, "/*SLICE:paths*/?", strings.Repeat(",?", len(paths))[1:], 1)
|
|
} else {
|
|
query = strings.Replace(query, "/*SLICE:paths*/?", "NULL", 1)
|
|
}
|
|
rows, err := q.db.QueryContext(ctx, query, queryParams...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []LookupTrackMetaByPathsRow
|
|
for rows.Next() {
|
|
var i LookupTrackMetaByPathsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.FilePath,
|
|
&i.Title,
|
|
&i.ArtistName,
|
|
); 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 searchAudioFilesByBasename = `-- name: SearchAudioFilesByBasename :many
|
|
SELECT
|
|
af.file_path,
|
|
af.length_milliseconds,
|
|
COALESCE(r.name, '') AS title,
|
|
COALESCE(ac.text, '') AS artist,
|
|
COALESCE(rg.name, '') AS album
|
|
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 (
|
|
SELECT recording_id, MIN(release_group_id) AS release_group_id
|
|
FROM release_group_recordings
|
|
GROUP BY recording_id
|
|
) rgr ON r.id = rgr.recording_id
|
|
LEFT JOIN release_groups rg ON rgr.release_group_id = rg.id
|
|
WHERE af.basename = ?
|
|
LIMIT ?
|
|
`
|
|
|
|
type SearchAudioFilesByBasenameParams struct {
|
|
Basename string
|
|
Limit int64
|
|
}
|
|
|
|
type SearchAudioFilesByBasenameRow struct {
|
|
FilePath string
|
|
LengthMilliseconds int64
|
|
Title string
|
|
Artist string
|
|
Album string
|
|
}
|
|
|
|
func (q *Queries) SearchAudioFilesByBasename(ctx context.Context, arg SearchAudioFilesByBasenameParams) ([]SearchAudioFilesByBasenameRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, searchAudioFilesByBasename, arg.Basename, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchAudioFilesByBasenameRow
|
|
for rows.Next() {
|
|
var i SearchAudioFilesByBasenameRow
|
|
if err := rows.Scan(
|
|
&i.FilePath,
|
|
&i.LengthMilliseconds,
|
|
&i.Title,
|
|
&i.Artist,
|
|
&i.Album,
|
|
); 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 updateAudioFile = `-- name: UpdateAudioFile :exec
|
|
UPDATE audio_files
|
|
SET file_path = ?, length_milliseconds = ?, file_type_id = ?, recording_id = ?, sample_rate = ?, bit_depth = ?, channels = ?, bitrate = ?, file_size = ?, basename = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type UpdateAudioFileParams struct {
|
|
FilePath string
|
|
LengthMilliseconds int64
|
|
FileTypeID int64
|
|
RecordingID int64
|
|
SampleRate int64
|
|
BitDepth int64
|
|
Channels int64
|
|
Bitrate int64
|
|
FileSize int64
|
|
Basename string
|
|
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.SampleRate,
|
|
arg.BitDepth,
|
|
arg.Channels,
|
|
arg.Bitrate,
|
|
arg.FileSize,
|
|
arg.Basename,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateAudioFileRecording = `-- name: UpdateAudioFileRecording :exec
|
|
UPDATE audio_files
|
|
SET recording_id = ?, sample_rate = ?, bit_depth = ?, channels = ?, bitrate = ?, file_size = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type UpdateAudioFileRecordingParams struct {
|
|
RecordingID int64
|
|
SampleRate int64
|
|
BitDepth int64
|
|
Channels int64
|
|
Bitrate int64
|
|
FileSize int64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateAudioFileRecording(ctx context.Context, arg UpdateAudioFileRecordingParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateAudioFileRecording,
|
|
arg.RecordingID,
|
|
arg.SampleRate,
|
|
arg.BitDepth,
|
|
arg.Channels,
|
|
arg.Bitrate,
|
|
arg.FileSize,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|