OLD | NEW |
1 package ignore | 1 package ignore |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "net/url" | 5 "net/url" |
6 "sync" | 6 "sync" |
7 "time" | 7 "time" |
8 ) | 8 ) |
9 | 9 |
10 // RuleMatcher returns a list of rules in the IgnoreStore that match the given | 10 // RuleMatcher returns a list of rules in the IgnoreStore that match the given |
(...skipping 22 matching lines...) Expand all Loading... |
33 // zero each time an IngoreStore is instantiated. | 33 // zero each time an IngoreStore is instantiated. |
34 Revision() int64 | 34 Revision() int64 |
35 | 35 |
36 // BuildRuleMatcher returns a RuleMatcher based on the current content | 36 // BuildRuleMatcher returns a RuleMatcher based on the current content |
37 // of the ignore store. | 37 // of the ignore store. |
38 BuildRuleMatcher() (RuleMatcher, error) | 38 BuildRuleMatcher() (RuleMatcher, error) |
39 } | 39 } |
40 | 40 |
41 // IgnoreRule is the GUI struct for dealing with Ignore rules. | 41 // IgnoreRule is the GUI struct for dealing with Ignore rules. |
42 type IgnoreRule struct { | 42 type IgnoreRule struct { |
43 » ID int `json:"id"` | 43 » ID int `json:"id"` |
44 » Name string `json:"name"` | 44 » Name string `json:"name"` |
45 » UpdatedBy string `json:"updatedBy"` | 45 » UpdatedBy string `json:"updatedBy"` |
46 » Expires time.Time `json:"expires"` | 46 » Expires time.Time `json:"expires"` |
47 » Query string `json:"query"` | 47 » Query string `json:"query"` |
48 » Note string `json:"note"` | 48 » Note string `json:"note"` |
49 » Count int `json:"count"` | 49 » Count int `json:"count"` |
| 50 » ExclusiveCount int `json:"exclusiveCount"` |
50 } | 51 } |
51 | 52 |
52 // ToQuery makes a slice of url.Values from the given slice of IngoreRules. | 53 // ToQuery makes a slice of url.Values from the given slice of IngoreRules. |
53 func ToQuery(ignores []*IgnoreRule) ([]url.Values, error) { | 54 func ToQuery(ignores []*IgnoreRule) ([]url.Values, error) { |
54 ret := []url.Values{} | 55 ret := []url.Values{} |
55 for _, ignore := range ignores { | 56 for _, ignore := range ignores { |
56 v, err := url.ParseQuery(ignore.Query) | 57 v, err := url.ParseQuery(ignore.Query) |
57 if err != nil { | 58 if err != nil { |
58 return nil, fmt.Errorf("Found an invaild ignore rule %d
%s: %s", ignore.ID, ignore.Query, err) | 59 return nil, fmt.Errorf("Found an invaild ignore rule %d
%s: %s", ignore.ID, ignore.Query, err) |
59 } | 60 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if !(ok && ruleValues[paramVal]) { | 198 if !(ok && ruleValues[paramVal]) { |
198 return false | 199 return false |
199 } | 200 } |
200 } | 201 } |
201 return true | 202 return true |
202 } | 203 } |
203 | 204 |
204 func noopRuleMatcher(p map[string]string) ([]*IgnoreRule, bool) { | 205 func noopRuleMatcher(p map[string]string) ([]*IgnoreRule, bool) { |
205 return nil, false | 206 return nil, false |
206 } | 207 } |
OLD | NEW |