ctrlsubsonic: sort getindexes and getartists views with COLLATE NOCASE

(hopefully) closes #61
This commit is contained in:
sentriz
2020-04-25 17:56:20 +01:00
parent 8d1c80cdc0
commit e90f581966
2 changed files with 4 additions and 10 deletions

View File

@@ -3,14 +3,13 @@ package ctrlsubsonic
import (
"fmt"
"net/http"
"sort"
"strings"
"github.com/jinzhu/gorm"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/db"
)
// the subsonic spec metions "artist" a lot when talking about the
@@ -26,6 +25,7 @@ func (c *Controller) ServeGetIndexes(r *http.Request) *spec.Response {
Joins("LEFT JOIN albums sub ON albums.id=sub.parent_id").
Where("albums.parent_id=1").
Group("albums.id").
Order("albums.right_path COLLATE NOCASE").
Find(&folders)
// [a-z#] -> 27
indexMap := make(map[string]*spec.Index, 27)
@@ -44,9 +44,6 @@ func (c *Controller) ServeGetIndexes(r *http.Request) *spec.Response {
index.Artists = append(index.Artists,
spec.NewArtistByFolder(folder))
}
sort.Slice(resp, func(i, j int) bool {
return resp[i].Name < resp[j].Name
})
sub := spec.NewResponse()
sub.Indexes = &spec.Indexes{
LastModified: 0,

View File

@@ -3,14 +3,13 @@ package ctrlsubsonic
import (
"fmt"
"net/http"
"sort"
"strings"
"github.com/jinzhu/gorm"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server/lastfm"
)
@@ -20,6 +19,7 @@ func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
Select("*, count(sub.id) album_count").
Joins("LEFT JOIN albums sub ON artists.id=sub.tag_artist_id").
Group("artists.id").
Order("artists.name COLLATE NOCASE").
Find(&artists)
// [a-z#] -> 27
indexMap := make(map[string]*spec.Index, 27)
@@ -38,9 +38,6 @@ func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
index.Artists = append(index.Artists,
spec.NewArtistByTags(artist))
}
sort.Slice(resp, func(i, j int) bool {
return resp[i].Name < resp[j].Name
})
sub := spec.NewResponse()
sub.Artists = &spec.Artists{
List: resp,