ctrlsubsonic: sort getindexes and getartists views with COLLATE NOCASE
(hopefully) closes #61
This commit is contained in:
@@ -3,14 +3,13 @@ package ctrlsubsonic
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
"go.senan.xyz/gonic/server/db"
|
|
||||||
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
|
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
|
||||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||||
|
"go.senan.xyz/gonic/server/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// the subsonic spec metions "artist" a lot when talking about the
|
// 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").
|
Joins("LEFT JOIN albums sub ON albums.id=sub.parent_id").
|
||||||
Where("albums.parent_id=1").
|
Where("albums.parent_id=1").
|
||||||
Group("albums.id").
|
Group("albums.id").
|
||||||
|
Order("albums.right_path COLLATE NOCASE").
|
||||||
Find(&folders)
|
Find(&folders)
|
||||||
// [a-z#] -> 27
|
// [a-z#] -> 27
|
||||||
indexMap := make(map[string]*spec.Index, 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,
|
index.Artists = append(index.Artists,
|
||||||
spec.NewArtistByFolder(folder))
|
spec.NewArtistByFolder(folder))
|
||||||
}
|
}
|
||||||
sort.Slice(resp, func(i, j int) bool {
|
|
||||||
return resp[i].Name < resp[j].Name
|
|
||||||
})
|
|
||||||
sub := spec.NewResponse()
|
sub := spec.NewResponse()
|
||||||
sub.Indexes = &spec.Indexes{
|
sub.Indexes = &spec.Indexes{
|
||||||
LastModified: 0,
|
LastModified: 0,
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ package ctrlsubsonic
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
"go.senan.xyz/gonic/server/db"
|
|
||||||
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
|
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
|
||||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||||
|
"go.senan.xyz/gonic/server/db"
|
||||||
"go.senan.xyz/gonic/server/lastfm"
|
"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").
|
Select("*, count(sub.id) album_count").
|
||||||
Joins("LEFT JOIN albums sub ON artists.id=sub.tag_artist_id").
|
Joins("LEFT JOIN albums sub ON artists.id=sub.tag_artist_id").
|
||||||
Group("artists.id").
|
Group("artists.id").
|
||||||
|
Order("artists.name COLLATE NOCASE").
|
||||||
Find(&artists)
|
Find(&artists)
|
||||||
// [a-z#] -> 27
|
// [a-z#] -> 27
|
||||||
indexMap := make(map[string]*spec.Index, 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,
|
index.Artists = append(index.Artists,
|
||||||
spec.NewArtistByTags(artist))
|
spec.NewArtistByTags(artist))
|
||||||
}
|
}
|
||||||
sort.Slice(resp, func(i, j int) bool {
|
|
||||||
return resp[i].Name < resp[j].Name
|
|
||||||
})
|
|
||||||
sub := spec.NewResponse()
|
sub := spec.NewResponse()
|
||||||
sub.Artists = &spec.Artists{
|
sub.Artists = &spec.Artists{
|
||||||
List: resp,
|
List: resp,
|
||||||
|
|||||||
Reference in New Issue
Block a user