aboutsummaryrefslogtreecommitdiffstats
path: root/cache/bug_excerpt.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-09 20:21:49 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-09 20:22:27 +0200
commit09e097e1bf32ad153c139e3f6befad9fb059fd6e (patch)
tree422db558f5ead4ec673bca6a2ede413514d49d5b /cache/bug_excerpt.go
parent21f9840e991ae569ec1efa404011e9a16ed2ab3b (diff)
downloadgit-bug-09e097e1bf32ad153c139e3f6befad9fb059fd6e.tar.gz
cache: combine sorting and filtering into a query with its micro-DSL
Diffstat (limited to 'cache/bug_excerpt.go')
-rw-r--r--cache/bug_excerpt.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go
index 94b46ccc..62b5eedb 100644
--- a/cache/bug_excerpt.go
+++ b/cache/bug_excerpt.go
@@ -22,8 +22,8 @@ type BugExcerpt struct {
Labels []bug.Label
}
-func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) BugExcerpt {
- return BugExcerpt{
+func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
+ return &BugExcerpt{
Id: b.Id(),
CreateLamportTime: b.CreateLamportTime(),
EditLamportTime: b.EditLamportTime(),
@@ -44,7 +44,21 @@ func init() {
* Sorting
*/
-type BugsByCreationTime []BugExcerpt
+type BugsById []*BugExcerpt
+
+func (b BugsById) Len() int {
+ return len(b)
+}
+
+func (b BugsById) Less(i, j int) bool {
+ return b[i].Id < b[j].Id
+}
+
+func (b BugsById) Swap(i, j int) {
+ b[i], b[j] = b[j], b[i]
+}
+
+type BugsByCreationTime []*BugExcerpt
func (b BugsByCreationTime) Len() int {
return len(b)
@@ -72,7 +86,7 @@ func (b BugsByCreationTime) Swap(i, j int) {
b[i], b[j] = b[j], b[i]
}
-type BugsByEditTime []BugExcerpt
+type BugsByEditTime []*BugExcerpt
func (b BugsByEditTime) Len() int {
return len(b)