diff options
Diffstat (limited to 'cache/repo_cache.go')
-rw-r--r-- | cache/repo_cache.go | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go index 3ce2f0c2..8f43ad71 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 |