summaryrefslogtreecommitdiffstatshomepage
path: root/cache
diff options
context:
space:
mode:
Diffstat (limited to 'cache')
-rw-r--r--cache/bug_excerpt.go4
-rw-r--r--cache/repo_cache.go55
2 files changed, 55 insertions, 4 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go
index 572f461a8..31e1951fa 100644
--- a/cache/bug_excerpt.go
+++ b/cache/bug_excerpt.go
@@ -42,7 +42,7 @@ func init() {
* Sorting
*/
-type BugsByCreationTime []*BugExcerpt
+type BugsByCreationTime []BugExcerpt
func (b BugsByCreationTime) Len() int {
return len(b)
@@ -70,7 +70,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)
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 3ce2f0c25..8f43ad71c 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"path"
+ "sort"
"strconv"
"strings"
@@ -203,8 +204,58 @@ func (c *RepoCache) ResolveBugPrefix(prefix string) (*BugCache, error) {
return cached, nil
}
-func (c *RepoCache) AllBugIds() ([]string, error) {
- return bug.ListLocalIds(c.repo)
+func (c *RepoCache) AllBugOrderById() []string {
+ result := make([]string, len(c.excerpts))
+
+ i := 0
+ for key := range c.excerpts {
+ result[i] = key
+ i++
+ }
+
+ sort.Strings(result)
+
+ return result
+}
+
+func (c *RepoCache) AllBugsOrderByEdit() []string {
+ excerpts := make([]BugExcerpt, len(c.excerpts))
+
+ i := 0
+ for _, val := range c.excerpts {
+ excerpts[i] = val
+ i++
+ }
+
+ sort.Sort(BugsByEditTime(excerpts))
+
+ result := make([]string, len(excerpts))
+
+ for i, val := range excerpts {
+ result[i] = val.Id
+ }
+
+ return result
+}
+
+func (c *RepoCache) AllBugsOrderByCreation() []string {
+ excerpts := make([]BugExcerpt, len(c.excerpts))
+
+ i := 0
+ for _, val := range c.excerpts {
+ excerpts[i] = val
+ i++
+ }
+
+ sort.Sort(BugsByCreationTime(excerpts))
+
+ result := make([]string, len(excerpts))
+
+ for i, val := range excerpts {
+ result[i] = val.Id
+ }
+
+ return result
}
// ClearAllBugs clear all bugs kept in memory