diff options
Diffstat (limited to 'cache')
-rw-r--r-- | cache/bug_excerpt.go | 8 | ||||
-rw-r--r-- | cache/filter.go | 16 | ||||
-rw-r--r-- | cache/repo_cache.go | 9 |
3 files changed, 31 insertions, 2 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go index fd06e51b..eae90f5a 100644 --- a/cache/bug_excerpt.go +++ b/cache/bug_excerpt.go @@ -23,8 +23,10 @@ type BugExcerpt struct { CreateUnixTime int64 EditUnixTime int64 - Status bug.Status - Labels []bug.Label + Title string + Status bug.Status + NoOfComments int + Labels []bug.Label // If author is identity.Bare, LegacyAuthor is set // If author is identity.Identity, AuthorId is set and data is deported @@ -48,8 +50,10 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt { EditLamportTime: b.EditLamportTime(), CreateUnixTime: b.FirstOp().GetUnixTime(), EditUnixTime: snap.LastEditUnix(), + Title: snap.Title, Status: snap.Status, Labels: snap.Labels, + NoOfComments: len(snap.Comments), CreateMetadata: b.FirstOp().AllMetadata(), } diff --git a/cache/filter.go b/cache/filter.go index 022a8ff2..a4254f2e 100644 --- a/cache/filter.go +++ b/cache/filter.go @@ -55,6 +55,17 @@ func LabelFilter(label string) Filter { } } +// TitleFilter return a Filter that match a title +func TitleFilter(title string) Filter { + return func(excerpt *BugExcerpt) bool { + if strings.Contains(excerpt.Title, title) { + return true + } + return false + } + +} + // NoLabelFilter return a Filter that match the absence of labels func NoLabelFilter() Filter { return func(repoCache *RepoCache, excerpt *BugExcerpt) bool { @@ -67,6 +78,7 @@ type Filters struct { Status []Filter Author []Filter Label []Filter + Title []Filter NoFilters []Filter } @@ -88,6 +100,10 @@ func (f *Filters) Match(repoCache *RepoCache, excerpt *BugExcerpt) bool { return false } + if match := f.andMatch(f.Title, excerpt); !match { + return false + } + return true } diff --git a/cache/repo_cache.go b/cache/repo_cache.go index 2b0fa360..fd5d0865 100644 --- a/cache/repo_cache.go +++ b/cache/repo_cache.go @@ -386,6 +386,15 @@ func (c *RepoCache) ResolveBug(id string) (*BugCache, error) { return cached, nil } +// ResolveBugExcerpt retrieve a BugExcerpt matching the exact given id +func (c *RepoCache) ResolveBugExcerpt(id string) (*BugExcerpt, error) { + e, ok := c.excerpts[id] + if !ok { + return nil, bug.ErrBugNotExist + } + + return e, nil +} // ResolveBugExcerpt retrieve a BugExcerpt matching the exact given id func (c *RepoCache) ResolveBugExcerpt(id string) (*BugExcerpt, error) { |