mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-03 19:00:05 -06:00
fix ordering of names (#3218)
This commit is contained in:
@@ -7,3 +7,4 @@ Example 2: https://localhost:9200/graph/v1.0/me/drives/?$orderby=name asc
|
||||
|
||||
https://github.com/owncloud/ocis/issues/3200
|
||||
https://github.com/owncloud/ocis/pull/3201
|
||||
https://github.com/owncloud/ocis/pull/3218
|
||||
|
||||
@@ -26,8 +26,8 @@ var drives = []*libregraph.Drive{
|
||||
drive("4", "project", "Richard", &time4),
|
||||
}
|
||||
var drivesLong = append(drives, []*libregraph.Drive{
|
||||
drive("5", "project", "Bob", time5),
|
||||
drive("6", "project", "Alice", time6),
|
||||
drive("5", "project", "bob", time5),
|
||||
drive("6", "project", "alice", time6),
|
||||
}...)
|
||||
|
||||
var sortTests = []sortTest{
|
||||
@@ -80,8 +80,8 @@ var sortTests = []sortTest{
|
||||
},
|
||||
DrivesSorted: []*libregraph.Drive{
|
||||
drive("3", "project", "Admin", time3),
|
||||
drive("6", "project", "Alice", time6),
|
||||
drive("5", "project", "Bob", time5),
|
||||
drive("6", "project", "alice", time6),
|
||||
drive("5", "project", "bob", time5),
|
||||
drive("1", "project", "Einstein", &time1),
|
||||
drive("2", "project", "Marie", &time2),
|
||||
drive("4", "project", "Richard", &time4),
|
||||
@@ -102,8 +102,8 @@ var sortTests = []sortTest{
|
||||
drive("4", "project", "Richard", &time4),
|
||||
drive("2", "project", "Marie", &time2),
|
||||
drive("1", "project", "Einstein", &time1),
|
||||
drive("5", "project", "Bob", time5),
|
||||
drive("6", "project", "Alice", time6),
|
||||
drive("5", "project", "bob", time5),
|
||||
drive("6", "project", "alice", time6),
|
||||
drive("3", "project", "Admin", time3),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
)
|
||||
|
||||
@@ -22,7 +24,7 @@ type spacesByLastModifiedDateTime struct {
|
||||
// Less reports whether the element with index i
|
||||
// must sort before the element with index j.
|
||||
func (s spacesByName) Less(i, j int) bool {
|
||||
return *s.spacesSlice[i].Name > *s.spacesSlice[j].Name
|
||||
return strings.ToLower(*s.spacesSlice[i].Name) > strings.ToLower(*s.spacesSlice[j].Name)
|
||||
}
|
||||
|
||||
// Less reports whether the element with index i
|
||||
@@ -41,5 +43,5 @@ func (s spacesByLastModifiedDateTime) Less(i, j int) bool {
|
||||
return true
|
||||
}
|
||||
// fallback to name if no dateTime is set on both items
|
||||
return *s.spacesSlice[i].Name > *s.spacesSlice[j].Name
|
||||
return strings.ToLower(*s.spacesSlice[i].Name) > strings.ToLower(*s.spacesSlice[j].Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user