lib/lazylead/task/alert.rb in lazylead-0.3.1 vs lib/lazylead/task/alert.rb in lazylead-0.4.0
- old
+ new
@@ -21,10 +21,11 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.
require_relative "../log"
+require_relative "../opts"
require_relative "../email"
require_relative "../version"
require_relative "../postman"
module Lazylead
@@ -41,16 +42,17 @@
# The task supports the following features:
# - fetch issues from remote ticketing system by query
# - prepare email based on predefined template (*.erb)
# - send the required notifications pre-defined "addressee".
class Alert
- def initialize(log = Log::NOTHING)
+ def initialize(log = Log.new)
@log = log
end
def run(sys, postman, opts)
- postman.send opts.merge(tickets: sys.issues(opts["sql"]))
+ tickets = sys.issues(opts["sql"], opts.jira_defaults)
+ postman.send opts.merge(tickets: tickets) unless tickets.empty?
end
end
#
# A task that sends notifications about issues to their assignees.
@@ -62,16 +64,16 @@
# - send the required notifications to each assignee
#
# The email message is sending to the assignee regarding all his/her issues,
# not like one email per each issue.
class AssigneeAlert
- def initialize(log = Log::NOTHING)
+ def initialize(log = Log.new)
@log = log
end
def run(sys, postman, opts)
- sys.issues(opts["sql"])
+ sys.issues(opts["sql"], opts.jira_defaults)
.group_by(&:assignee)
.each do |a, t|
postman.send opts.merge(to: a.email, addressee: a.name, tickets: t)
end
end
@@ -87,15 +89,15 @@
# - send the required notifications to each reporter
#
# The email message is sending to the assignee regarding all his/her issues,
# not like one email per each issue.
class ReporterAlert
- def initialize(log = Log::NOTHING)
+ def initialize(log = Log.new)
@log = log
end
def run(sys, postman, opts)
- sys.issues(opts["sql"])
+ sys.issues(opts["sql"], opts.jira_defaults)
.group_by(&:reporter)
.each do |a, t|
postman.send opts.merge(to: a.email, addressee: a.name, tickets: t)
end
end