aboutsummaryrefslogtreecommitdiffstats
path: root/cache/filter.go
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-03-31 22:32:35 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-04-04 00:37:57 +0200
commit2a5fbc4dc988d2eea76fe5e844ccf6425f9386ee (patch)
tree8e5125a64ff3d54fa304ae758ddbbcc427b368af /cache/filter.go
parent5b0a92dea43f467f31a65a6f02e937d285cb0a71 (diff)
downloadgit-bug-2a5fbc4dc988d2eea76fe5e844ccf6425f9386ee.tar.gz
Expose actors and participants in snapshot and bug excerpt
Append operations authors to each list on Apply() call Expose actors and participants in graphql Add actor/participant query filter and documentation
Diffstat (limited to 'cache/filter.go')
-rw-r--r--cache/filter.go54
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
}