🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Sorting Artist Index on save
Deluan74478ce6f9ba
diff --git a/repositories/index_repository.go b/repositories/index_repository.goindex 05adbdfdd..ef02468cb 100644--- a/repositories/index_repository.go+++ b/repositories/index_repository.go@@ -27,6 +27,7 @@ func (r *artistIndex) Put(m *models.ArtistIndex) error {if m.Id == "" {return errors.New("Id is not set")}+ sort.Sort(byArtistName(m.Artists))return r.saveOrUpdate(m.Id, m)}@@ -39,16 +40,17 @@ func (r *artistIndex) Get(id string) (*models.ArtistIndex, error) {func (r *artistIndex) GetAll() ([]models.ArtistIndex, error) {var indices = make([]models.ArtistIndex, 0)err := r.loadAll(&indices, "")- if err == nil {- for _, idx := range indices {- sort.Sort(byArtistName(idx.Artists))- }- }return indices, err}type byArtistName []models.ArtistInfo-func (a byArtistName) Len() int { return len(a) }-func (a byArtistName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }-func (a byArtistName) Less(i, j int) bool { return utils.NoArticle(a[i].Artist) < utils.NoArticle(a[j].Artist) }+func (a byArtistName) Len() int {+ return len(a)+}+func (a byArtistName) Swap(i, j int) {+ a[i], a[j] = a[j], a[i]+}+func (a byArtistName) Less(i, j int) bool {+ return utils.NoArticle(a[i].Artist) < utils.NoArticle(a[j].Artist)+}