Class: Lazylead::Task::Micromanager

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

Overview

Email alerts about due date modification by not-authorized persons.

Author

Yurii Dubinka ([email protected])

Copyright

Copyright © 2019-2020 Yurii Dubinka

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(log = Log.new) ⇒ Micromanager

Returns a new instance of Micromanager.



39
40
41
# File 'lib/lazylead/task/micromanager.rb', line 39

def initialize(log = Log.new)
  @log = log
end

Instance Method Details

#run(sys, postman, opts) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/lazylead/task/micromanager.rb', line 43

def run(sys, postman, opts)
  allowed = opts.slice "allowed", ","
  dues = sys.issues(opts["jql"], opts.jira_defaults.merge(expand: "changelog"))
            .map { |i| Due.new(i, allowed, since(opts)) }
            .select(&:illegal?)
            .reject(&:obsolete?)
  return if dues.empty?
  postman.send opts.merge(dues: dues)
end

#since(opts) ⇒ Object

Detect history period where search should start.

opts The default period for past is 1 day (86400 seconds).

So, if now 2017-04-06 15:50:58.674+0000
it returns 2017-04-05 15:50:58 +0000

opts The current time for unit tests.

If absent the "Time.now" is used.


62
63
64
65
66
67
68
# File 'lib/lazylead/task/micromanager.rb', line 62

def since(opts)
  @since ||= if opts.key? "now"
               Time.parse(opts["now"])
             else
               Time.now - opts.fetch("period", "86400").to_i
             end
end