Skip to content

Commit

Permalink
feat: add support of tag parsing in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagriar committed Mar 30, 2023
1 parent 1f720e4 commit 6bc0750
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions algolia/search/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Rule struct {
Enabled *opt.EnabledOption `json:"enabled,omitempty"`
ObjectID string `json:"objectID,omitempty"`
Validity []TimeRange `json:"validity,omitempty"`
Tags []string `json:"tags,omitempty"`
}

// TimeRange is a pair of begin/end time.Time used to represent a rule validity
Expand Down
6 changes: 6 additions & 0 deletions algolia/search/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func TestRule_MarshalJSON(t *testing.T) {
},
`{"condition":{"anchoring":"is","pattern":"Pattern","context":"Context","alternatives":true},"consequence":{}}`,
},
{
Rule{
Tags: []string{"visual-editor"},
},
`{"consequence":{},"tags":["visual-editor"]}`,
},
} {
// Encode the Rule to JSON
data, err := json.Marshal(&c.rule)
Expand Down

0 comments on commit 6bc0750

Please sign in to comment.