2023-01-15 20:11:37 +00:00
|
|
|
package model
|
|
|
|
|
|
2026-03-18 18:57:33 -04:00
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/navidrome/navidrome/consts"
|
|
|
|
|
)
|
2023-01-15 20:11:37 +00:00
|
|
|
|
|
|
|
|
type Radio struct {
|
2026-07-22 20:06:13 -04:00
|
|
|
ItemImage `structs:"-" json:"-"`
|
|
|
|
|
|
2026-03-18 18:57:33 -04:00
|
|
|
ID string `structs:"id" json:"id"`
|
|
|
|
|
StreamUrl string `structs:"stream_url" json:"streamUrl"`
|
|
|
|
|
Name string `structs:"name" json:"name"`
|
|
|
|
|
HomePageUrl string `structs:"home_page_url" json:"homePageUrl"`
|
|
|
|
|
UploadedImage string `structs:"uploaded_image" json:"uploadedImage,omitempty"`
|
|
|
|
|
CreatedAt time.Time `structs:"created_at" json:"createdAt"`
|
|
|
|
|
UpdatedAt time.Time `structs:"updated_at" json:"updatedAt"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r Radio) CoverArtID() ArtworkID {
|
|
|
|
|
return artworkIDFromRadio(r)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r Radio) UploadedImagePath() string {
|
|
|
|
|
return UploadedImagePath(consts.EntityRadio, r.UploadedImage)
|
2023-01-15 20:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Radios []Radio
|
|
|
|
|
|
|
|
|
|
type RadioRepository interface {
|
|
|
|
|
ResourceRepository
|
|
|
|
|
CountAll(options ...QueryOptions) (int64, error)
|
|
|
|
|
Delete(id string) error
|
|
|
|
|
Get(id string) (*Radio, error)
|
|
|
|
|
GetAll(options ...QueryOptions) (Radios, error)
|
perf(artwork): fetch only IDs for backfill enumeration
Backfill enumerated every album, artist, playlist and radio via GetAll
and mapped out just the ID. GetAll materializes full entities (library
joins, participant/stats/tags JSON, annotation, artwork hydration), so on
a large library it loaded tens of thousands of heavy structs only to read
one field each — spiking transient RSS to ~1GB during the one-time
upgrade backfill, a memory risk on small NAS/Pi hardware.
Add GetAllIDs to the album, artist, playlist and radio repositories: it
reuses each repo's base row-set filter (library visibility, artist
content join, playlist userFilter) but projects only id, skipping the
heavy columns and post-processing. A per-repo parity test asserts
GetAllIDs returns exactly the same id set as GetAll.
Verified on a 727MB / 29k-artist production DB copy: peak RSS during
backfill dropped from ~1012MB to ~89MB, file descriptors flat, same
36,138 items enqueued.
2026-07-23 13:20:22 -04:00
|
|
|
GetAllIDs(options ...QueryOptions) ([]string, error)
|
2026-03-18 18:57:33 -04:00
|
|
|
Put(u *Radio, colsToUpdate ...string) error
|
2023-01-15 20:11:37 +00:00
|
|
|
}
|