Class: Remind::Service::Scheduler
- Inherits:
-
Object
- Object
- Remind::Service::Scheduler
- Extended by:
- Helper::ErrorHandler, Helper::LogHandler
- Defined in:
- lib/remind/services/scheduler.rb
Class Method Summary collapse
-
.start ⇒ Object
Notify due tasks.
Methods included from Helper::ErrorHandler
Methods included from Helper::LogHandler
Class Method Details
.start ⇒ Object
Notify due tasks
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/remind/services/scheduler.rb', line 17 def self.start handle_errors do tasks = TmsTaskManager::Services::TaskList.list puts tasks # binding.pry = [] tasks.each do |task| start_date = Time.parse(task['start_date']) due_date = Time.parse(task['end_date']) status = task['status'] task_name = task['title'] if status == 'completed' create_log(Logger::INFO, "Task '#{task_name}' (Completed: #{due_date.strftime('%Y-%m-%d')})") elsif Time.now < start_date create_log(Logger::INFO, "Task '#{task_name}' (Not Started: #{start_date.strftime('%Y-%m-%d')})") elsif Time.now <= due_date create_log(Logger::INFO, "Task '#{task_name}' (In Progress: from #{start_date.strftime('%Y-%m-%d')} to #{due_date.strftime('%Y-%m-%d')})") else create_log(Logger::ERROR, "Task '#{task_name}' (Overdue: from #{start_date.strftime('%Y-%m-%d')} to #{due_date.strftime('%Y-%m-%d')})") << "Task '#{task_name}' (Overdue: from #{start_date.strftime('%Y-%m-%d')} to #{due_date.strftime('%Y-%m-%d')})" end end Remind::Service::Notifier.notify(.join("\n")) end end |