diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-02 16:36:48 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-02 16:36:48 +0200 |
commit | 0728c0050d82171659474900c407e1b6dcee43a5 (patch) | |
tree | 73473697a596bb0e93b30ab9a68fd25e7c3af98c /cache/repo_cache.go | |
parent | e3c445fa85db65b084580a38b919f17b8f8c2b68 (diff) | |
download | git-bug-0728c0050d82171659474900c407e1b6dcee43a5.tar.gz |
cache: provide a generic bug sorting function
Diffstat (limited to 'cache/repo_cache.go')
-rw-r--r-- | cache/repo_cache.go | 67 |
1 files changed, 12 insertions, 55 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go index 8f43ad71..d5dd4c59 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -8,7 +8,6 @@ import ( "io/ioutil" "os" "path" - "sort" "strconv" "strings" @@ -154,6 +153,18 @@ func (c *RepoCache) buildAllExcerpt() { } } +func (c *RepoCache) allExcerpt() []BugExcerpt { + result := make([]BugExcerpt, len(c.excerpts)) + + i := 0 + for _, val := range c.excerpts { + result[i] = val + i++ + } + + return result +} + func (c *RepoCache) ResolveBug(id string) (*BugCache, error) { cached, ok := c.bugs[id] if ok { @@ -204,60 +215,6 @@ func (c *RepoCache) ResolveBugPrefix(prefix string) (*BugCache, error) { return cached, nil } -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 func (c *RepoCache) ClearAllBugs() { c.bugs = make(map[string]*BugCache) |