Files
minstrel/internal/db/dbq/library_settings.sql.go
T
bvandeusenandClaude Opus 5.5 55c7497ca7
release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
feat: Minstrel stops acquiring music and drops Discover
Minstrel is now a viewer of the library it is pointed at. Finding,
downloading and filing music moves out of it.

Removed from the server:
- the request flow (requests, approval, auto-approve) and the wanted list,
  follows, release profiles and release blocks;
- searching indexers, the download clients, the importer, the album
  lifecycle and missing-file re-acquisition;
- the catalogue's discography, search and art (the MusicBrainz release and
  track-list cache stays, for the duplicate resolver);
- Discover: its suggestions of artists not in the library, snoozes, the
  candidate-artist tag enrichment and its tuning scope;
- writes to acquisition tables from moving the library folder and from
  merging duplicates, the want-list join on Suspect sources, the sealing of
  acquisition credentials, and the release-group lookup only
  re-acquisition used.

Settling a wrong-slot duplicate no longer sets the release aside: the
copies go and their slots show as missing until a good copy is in the
library.

Removed from the web: Admin > Acquisition and Requests, /requests,
/discover, Follow on the artist page, the auto-approve toggle, and the
Collection's wanted-list tabs. The Collection is now the library's health:
an overview, Reports, Duplicates, Suspect sources and Missing files. The
README and docs no longer describe getting music.

The tables stay for now; a later migration drops them. The request
notification kinds and the Android screens are still to go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:51:14 -05:00

124 lines
3.5 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: library_settings.sql
package dbq
import (
"context"
)
const countTracksUnder = `-- name: CountTracksUnder :one
SELECT count(*) FROM tracks WHERE starts_with(file_path, $1::text || '/')
`
func (q *Queries) CountTracksUnder(ctx context.Context, root string) (int64, error) {
row := q.db.QueryRow(ctx, countTracksUnder, root)
var count int64
err := row.Scan(&count)
return count, err
}
const getLibrarySettings = `-- name: GetLibrarySettings :one
SELECT id, scan_paths, updated_at FROM library_settings WHERE id = true
`
func (q *Queries) GetLibrarySettings(ctx context.Context) (LibrarySetting, error) {
row := q.db.QueryRow(ctx, getLibrarySettings)
var i LibrarySetting
err := row.Scan(&i.ID, &i.ScanPaths, &i.UpdatedAt)
return i, err
}
const rerootAlbumCoverPaths = `-- name: RerootAlbumCoverPaths :execrows
UPDATE albums
SET cover_art_path = $1::text || substr(cover_art_path, length($2::text) + 1)
WHERE starts_with(cover_art_path, $2::text || '/')
`
type RerootAlbumCoverPathsParams struct {
NewRoot string
OldRoot string
}
func (q *Queries) RerootAlbumCoverPaths(ctx context.Context, arg RerootAlbumCoverPathsParams) (int64, error) {
result, err := q.db.Exec(ctx, rerootAlbumCoverPaths, arg.NewRoot, arg.OldRoot)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const rerootTrackPaths = `-- name: RerootTrackPaths :execrows
UPDATE tracks
SET file_path = $1::text || substr(file_path, length($2::text) + 1)
WHERE starts_with(file_path, $2::text || '/')
`
type RerootTrackPathsParams struct {
NewRoot string
OldRoot string
}
// A library folder that moved: every path under old_root is rewritten
// to the same place under new_root, so the tracks keep their ids and with them
// their plays, likes and playlists. updated_at is left alone on purpose: the
// scan compares it with each file's mtime, and the files have not changed.
func (q *Queries) RerootTrackPaths(ctx context.Context, arg RerootTrackPathsParams) (int64, error) {
result, err := q.db.Exec(ctx, rerootTrackPaths, arg.NewRoot, arg.OldRoot)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const sampleTrackPathsUnder = `-- name: SampleTrackPathsUnder :many
SELECT file_path FROM tracks
WHERE starts_with(file_path, $1::text || '/') AND missing_since IS NULL
ORDER BY random()
LIMIT $2::int
`
type SampleTrackPathsUnderParams struct {
Root string
N int32
}
// A few present tracks under a folder, to check a move before rewriting it.
func (q *Queries) SampleTrackPathsUnder(ctx context.Context, arg SampleTrackPathsUnderParams) ([]string, error) {
rows, err := q.db.Query(ctx, sampleTrackPathsUnder, arg.Root, arg.N)
if err != nil {
return nil, err
}
defer rows.Close()
var items []string
for rows.Next() {
var file_path string
if err := rows.Scan(&file_path); err != nil {
return nil, err
}
items = append(items, file_path)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateLibraryScanPaths = `-- name: UpdateLibraryScanPaths :one
UPDATE library_settings
SET scan_paths = $1::text[],
updated_at = now()
WHERE id = true
RETURNING id, scan_paths, updated_at
`
func (q *Queries) UpdateLibraryScanPaths(ctx context.Context, scanPaths []string) (LibrarySetting, error) {
row := q.db.QueryRow(ctx, updateLibraryScanPaths, scanPaths)
var i LibrarySetting
err := row.Scan(&i.ID, &i.ScanPaths, &i.UpdatedAt)
return i, err
}