mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-14 11:17:19 +03:00
Add all individual artists from album in searchable full text field. Should fix #94
This commit is contained in:
parent
b8d1185f7f
commit
43ce81af67
@ -34,7 +34,6 @@ type Albums []Album
|
|||||||
type AlbumRepository interface {
|
type AlbumRepository interface {
|
||||||
CountAll(...QueryOptions) (int64, error)
|
CountAll(...QueryOptions) (int64, error)
|
||||||
Exists(id string) (bool, error)
|
Exists(id string) (bool, error)
|
||||||
Put(m *Album) error
|
|
||||||
Get(id string) (*Album, error)
|
Get(id string) (*Album, error)
|
||||||
FindByArtist(albumArtistId string) (Albums, error)
|
FindByArtist(albumArtistId string) (Albums, error)
|
||||||
GetAll(...QueryOptions) (Albums, error)
|
GetAll(...QueryOptions) (Albums, error)
|
||||||
|
@ -65,12 +65,6 @@ func (r *albumRepository) Exists(id string) (bool, error) {
|
|||||||
return r.exists(Select().Where(Eq{"id": id}))
|
return r.exists(Select().Where(Eq{"id": id}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *albumRepository) Put(a *model.Album) error {
|
|
||||||
a.FullText = r.getFullText(a.Name, a.Artist, a.AlbumArtist)
|
|
||||||
_, err := r.put(a.ID, a)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *albumRepository) selectAlbum(options ...model.QueryOptions) SelectBuilder {
|
func (r *albumRepository) selectAlbum(options ...model.QueryOptions) SelectBuilder {
|
||||||
return r.newSelectWithAnnotation("album.id", options...).Columns("*")
|
return r.newSelectWithAnnotation("album.id", options...).Columns("*")
|
||||||
}
|
}
|
||||||
@ -113,11 +107,13 @@ func (r *albumRepository) Refresh(ids ...string) error {
|
|||||||
model.Album
|
model.Album
|
||||||
CurrentId string
|
CurrentId string
|
||||||
HasCoverArt bool
|
HasCoverArt bool
|
||||||
|
SongArtists string
|
||||||
}
|
}
|
||||||
var albums []refreshAlbum
|
var albums []refreshAlbum
|
||||||
sel := Select(`album_id as id, album as name, f.artist, f.album_artist, f.artist_id, f.album_artist_id,
|
sel := Select(`album_id as id, album as name, f.artist, f.album_artist, f.artist_id, f.album_artist_id,
|
||||||
f.compilation, f.genre, max(f.year) as max_year, min(f.year) as min_year, sum(f.duration) as duration,
|
f.compilation, f.genre, max(f.year) as max_year, min(f.year) as min_year, sum(f.duration) as duration,
|
||||||
count(*) as song_count, a.id as current_id, f.id as cover_art_id, f.path as cover_art_path, f.has_cover_art`).
|
count(*) as song_count, a.id as current_id, f.id as cover_art_id, f.path as cover_art_path,
|
||||||
|
group_concat(f.artist, ' ') as song_artists, f.has_cover_art`).
|
||||||
From("media_file f").
|
From("media_file f").
|
||||||
LeftJoin("album a on f.album_id = a.id").
|
LeftJoin("album a on f.album_id = a.id").
|
||||||
Where(Eq{"f.album_id": ids}).GroupBy("album_id").OrderBy("f.id")
|
Where(Eq{"f.album_id": ids}).GroupBy("album_id").OrderBy("f.id")
|
||||||
@ -147,7 +143,8 @@ func (r *albumRepository) Refresh(ids ...string) error {
|
|||||||
toInsert++
|
toInsert++
|
||||||
al.CreatedAt = time.Now()
|
al.CreatedAt = time.Now()
|
||||||
}
|
}
|
||||||
err := r.Put(&al.Album)
|
al.FullText = r.getFullText(al.Name, al.Artist, al.AlbumArtist, al.SongArtists)
|
||||||
|
_, err := r.put(al.ID, al.Album)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,9 @@ var _ = Describe("Initialize test DB", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alr := NewAlbumRepository(ctx, o)
|
alr := NewAlbumRepository(ctx, o).(*albumRepository)
|
||||||
for _, a := range testAlbums {
|
for _, a := range testAlbums {
|
||||||
err := alr.Put(&a)
|
_, err := alr.put(a.ID, &a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user