Default sorts should be in the domain

This commit is contained in:
Deluan
2016-03-03 21:42:12 -05:00
parent fc6d49d34c
commit 5ca9680059
4 changed files with 17 additions and 28 deletions
+10 -1
View File
@@ -1,5 +1,7 @@
package domain
import "github.com/deluan/gosonic/utils"
type ArtistInfo struct {
ArtistId string
Artist string
@@ -7,7 +9,14 @@ type ArtistInfo struct {
type ArtistIndex struct {
Id string
Artists []ArtistInfo
Artists ArtistInfos
}
type ArtistInfos []ArtistInfo
func (a ArtistInfos) Len() int { return len(a) }
func (a ArtistInfos) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ArtistInfos) Less(i, j int) bool {
return utils.NoArticle(a[i].Artist) < utils.NoArticle(a[j].Artist)
}
type ArtistIndexes []ArtistIndex
+5
View File
@@ -33,6 +33,11 @@ func (mf *MediaFile) ContentType() string {
}
type MediaFiles []MediaFile
func (a MediaFiles) Len() int { return len(a) }
func (a MediaFiles) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a MediaFiles) Less(i, j int) bool {
return (a[i].DiscNumber * 1000 + a[i].TrackNumber) < (a[j].DiscNumber * 1000 + a[j].TrackNumber)
}
type MediaFileRepository interface {
BaseRepository