-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default sorting for decks, groups and group members (#264)
* feat: implemented default sorting for decks, groups and group members * added toLower operation & sorted pending members
- Loading branch information
Showing
6 changed files
with
50 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package comparators | ||
|
||
import "github.com/kioku-project/kioku/pkg/model" | ||
|
||
func CardModelDateComparator(a, b model.Card) int { | ||
return a.CreatedAt.Compare(b.CreatedAt) | ||
} | ||
|
||
func DeckModelDateComparator(a, b model.Deck) int { | ||
return a.CreatedAt.Compare(b.CreatedAt) | ||
} | ||
|
||
func GroupModelDateComparator(a, b model.Group) int { | ||
return a.CreatedAt.Compare(b.CreatedAt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package comparators | ||
|
||
import ( | ||
pbCommon "github.com/kioku-project/kioku/pkg/proto" | ||
"strings" | ||
) | ||
|
||
func GroupUserProtoRoleComparator(a, b *pbCommon.User) int { | ||
if val := int(b.GroupRole.Number()) - int(a.GroupRole.Number()); val != 0 { | ||
return val | ||
} | ||
return strings.Compare(strings.ToLower(a.UserName), strings.ToLower(b.UserName)) | ||
} | ||
|
||
func UserProtoNameComparator(a, b *pbCommon.User) int { | ||
return strings.Compare(strings.ToLower(a.UserName), strings.ToLower(b.UserName)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters