Add sort tags and use them in search

This commit is contained in:
Deluan
2020-04-24 10:13:59 -04:00
committed by Deluan Quintão
parent d7edbf93f0
commit 69c19e946c
10 changed files with 177 additions and 49 deletions
+4 -1
View File
@@ -115,6 +115,8 @@ func (r *albumRepository) Refresh(ids ...string) error {
}
var albums []refreshAlbum
sel := Select(`album_id as id, album as name, f.artist, f.album_artist, f.artist_id, f.album_artist_id,
f.sort_album_name, f.sort_artist_name, f.sort_album_artist_name,
f.order_album_name, f.order_album_artist_name,
f.compilation, f.genre, max(f.year) as max_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,
group_concat(f.artist, ' ') as song_artists, group_concat(f.year, ' ') as years`).
@@ -148,7 +150,8 @@ func (r *albumRepository) Refresh(ids ...string) error {
toInsert++
al.CreatedAt = time.Now()
}
al.FullText = getFullText(al.Name, al.Artist, al.AlbumArtist, al.SongArtists)
al.FullText = getFullText(al.Name, al.Artist, al.AlbumArtist, al.SongArtists,
al.SortAlbumName, al.SortArtistName, al.SortAlbumArtistName)
_, err := r.put(al.ID, al.Album)
if err != nil {
return err
+4 -2
View File
@@ -56,7 +56,7 @@ func (r *artistRepository) getIndexKey(a *model.Artist) string {
}
func (r *artistRepository) Put(a *model.Artist) error {
a.FullText = getFullText(a.Name)
a.FullText = getFullText(a.Name, a.SortArtistName)
_, err := r.put(a.ID, a)
return err
}
@@ -111,7 +111,9 @@ func (r *artistRepository) Refresh(ids ...string) error {
CurrentId string
}
var artists []refreshArtist
sel := Select("f.album_artist_id as id", "f.album_artist as name", "count(*) as album_count", "a.id as current_id").
sel := Select("f.album_artist_id as id", "f.album_artist as name", "count(*) as album_count", "a.id as current_id",
"f.sort_album_artist_name as sort_artist_name",
"f.order_album_artist_name as order_artist_name").
From("album f").
LeftJoin("artist a on f.album_artist_id = a.id").
Where(Eq{"f.album_artist_id": ids}).
+2 -1
View File
@@ -41,7 +41,8 @@ func (r mediaFileRepository) Exists(id string) (bool, error) {
}
func (r mediaFileRepository) Put(m *model.MediaFile) error {
m.FullText = getFullText(m.Title, m.Album, m.Artist, m.AlbumArtist)
m.FullText = getFullText(m.Title, m.Album, m.Artist, m.AlbumArtist,
m.SortTitle, m.SortAlbumName, m.SortArtistName, m.SortAlbumArtistName)
_, err := r.put(m.ID, m)
return err
}