diff options
Diffstat (limited to 'cache/filter.go')
-rw-r--r-- | cache/filter.go | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/cache/filter.go b/cache/filter.go index 7f010608..48ee6678 100644 --- a/cache/filter.go +++ b/cache/filter.go @@ -55,6 +55,40 @@ func LabelFilter(label string) Filter { } } +// ActorFilter return a Filter that match a bug actor +func ActorFilter(actor string) Filter { + return func(repoCache *RepoCache, excerpt *BugExcerpt) bool { + for _, identityExcerpt := range repoCache.identitiesExcerpts { + if strings.Contains(strings.ToLower(identityExcerpt.Name), actor) || + actor == identityExcerpt.Id || actor == identityExcerpt.Login { + for _, actorId := range excerpt.Actors { + if identityExcerpt.Id == actorId { + return true + } + } + } + } + return false + } +} + +// ParticipantFilter return a Filter that match a bug participant +func ParticipantFilter(participant string) Filter { + return func(repoCache *RepoCache, excerpt *BugExcerpt) bool { + for _, identityExcerpt := range repoCache.identitiesExcerpts { + if strings.Contains(strings.ToLower(identityExcerpt.Name), participant) || + participant == identityExcerpt.Id || participant == identityExcerpt.Login { + for _, participantId := range excerpt.Participants { + if identityExcerpt.Id == participantId { + return true + } + } + } + } + return false + } +} + // TitleFilter return a Filter that match if the title contains the given query func TitleFilter(query string) Filter { return func(repo *RepoCache, excerpt *BugExcerpt) bool { @@ -74,11 +108,13 @@ func NoLabelFilter() Filter { // Filters is a collection of Filter that implement a complex filter type Filters struct { - Status []Filter - Author []Filter - Label []Filter - Title []Filter - NoFilters []Filter + Status []Filter + Author []Filter + Actor []Filter + Participant []Filter + Label []Filter + Title []Filter + NoFilters []Filter } // Match check if a bug match the set of filters @@ -91,6 +127,14 @@ func (f *Filters) Match(repoCache *RepoCache, excerpt *BugExcerpt) bool { return false } + if match := f.orMatch(f.Participant, repoCache, excerpt); !match { + return false + } + + if match := f.orMatch(f.Actor, repoCache, excerpt); !match { + return false + } + if match := f.andMatch(f.Label, repoCache, excerpt); !match { return false } |