Class: Career::Task
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Career::Task
- Defined in:
- app/models/career/task.rb
Constant Summary collapse
- VALID_STATUSES =
['scheduled', 'started', 'complete', 'failed', 'interrupted', 'canceled']
Instance Method Summary collapse
- #enqueue ⇒ Object
- #enqueue_at(scheduled_date) ⇒ Object
- #log(content, entry_type = 'info', data = nil) ⇒ Object
- #set_status(status) ⇒ Object
- #update_percent_complete(percent_complete) ⇒ Object
Instance Method Details
#enqueue ⇒ Object
21 22 23 |
# File 'app/models/career/task.rb', line 21 def enqueue Resque.enqueue(class_name.constantize, id, *params) end |
#enqueue_at(scheduled_date) ⇒ Object
25 26 27 |
# File 'app/models/career/task.rb', line 25 def enqueue_at(scheduled_date) Resque.enqueue_at(scheduled_date, class_name.constantize, id, *params) end |
#log(content, entry_type = 'info', data = nil) ⇒ Object
29 30 31 32 33 34 |
# File 'app/models/career/task.rb', line 29 def log(content, entry_type='info', data=nil) task_log_entry = task_log_entries.create(content: content, entry_type: entry_type, data: data) # TODO: Implement #TaskLogEntriesChannel.broadcast_to(self, task_log_entry) end |
#set_status(status) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/career/task.rb', line 36 def set_status(status) updated_attributes = { status: status } if status == 'started' updated_attributes[:percent_complete] = 0 updated_attributes[:started_at] = Time.now end if status == 'complete' updated_attributes[:percent_complete] = 100 updated_attributes[:completed_at] = Time.now end self.update(updated_attributes) # TODO: Implement #TasksChannel.broadcast_to(self, self) end |
#update_percent_complete(percent_complete) ⇒ Object
55 56 57 58 59 60 |
# File 'app/models/career/task.rb', line 55 def update_percent_complete(percent_complete) self.update(percent_complete: percent_complete) # TODO: Implement #TasksChannel.broadcast_to(self, self) end |