Class: Lazylead::Task::AlertIf

Inherits:
Object
  • Object
show all
Defined in:
lib/lazylead/task/alert/alertif.rb

Overview

TODO:

#334:DEV AlertIf should support rules for bulk issues. For now each rule works per issue

Send an alert if expected conditions are met.

The task supports the following features:

- fetch issues from remote ticketing system by query
- evaluate set of rules for each ticket
- send an email

Instance Method Summary collapse

Instance Method Details

#run(sys, postman, opts) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/lazylead/task/alert/alertif.rb', line 42

def run(sys, postman, opts)
  Requires.new(__dir__).load
  opts[:rules] = opts.construct("rules")
  sys.issues(opts["jql"], opts.jira_defaults.merge(expand: "changelog"))
     .map { |i| When.new(i, opts) }
     .select(&:matches)
     .group_by(&:assignee)
     .each { |a, t| postman.send opts.merge(to: a.email, addressee: a.name, tickets: t) }
end