Class: Task
- Inherits:
-
MLS::Model
- Object
- ActiveRecord::Base
- MLS::Model
- Task
- Defined in:
- lib/mls/models/task.rb
Instance Method Summary collapse
- #crawl? ⇒ Boolean
- #duration ⇒ Object
- #fix? ⇒ Boolean
- #for_source? ⇒ Boolean
- #for_task? ⇒ Boolean
- #parse? ⇒ Boolean
- #pause ⇒ Object
- #paused? ⇒ Boolean
- #resume ⇒ Object
- #review? ⇒ Boolean
Instance Method Details
#crawl? ⇒ Boolean
37 38 39 |
# File 'lib/mls/models/task.rb', line 37 def crawl? type == "crawl" end |
#duration ⇒ Object
45 46 47 |
# File 'lib/mls/models/task.rb', line 45 def duration time_logs.where(TimeLog.arel_table[:started_at].not_eq(nil)).where(TimeLog.arel_table[:stopped_at].not_eq(nil)).sum("duration") end |
#fix? ⇒ Boolean
29 30 31 |
# File 'lib/mls/models/task.rb', line 29 def fix? type == "fix" end |
#for_source? ⇒ Boolean
17 18 19 |
# File 'lib/mls/models/task.rb', line 17 def for_source? subject_type == "Source" end |
#for_task? ⇒ Boolean
21 22 23 |
# File 'lib/mls/models/task.rb', line 21 def for_task? subject_type == "Task" end |
#parse? ⇒ Boolean
33 34 35 |
# File 'lib/mls/models/task.rb', line 33 def parse? type == "parse" end |
#pause ⇒ Object
49 50 51 52 53 54 |
# File 'lib/mls/models/task.rb', line 49 def pause log = time_logs.where(:stopped_at => nil).where(TimeLog.arel_table[:started_at].not_eq(nil)).first if log log.update(:stopped_at => Time.now) end end |
#paused? ⇒ Boolean
41 42 43 |
# File 'lib/mls/models/task.rb', line 41 def paused? status == 'paused' end |
#resume ⇒ Object
56 57 58 59 |
# File 'lib/mls/models/task.rb', line 56 def resume #time_logs << TimeLog.create(:started_at => Time.now) TimeLog.create(task_id: self.id, started_at: Time.now) end |
#review? ⇒ Boolean
25 26 27 |
# File 'lib/mls/models/task.rb', line 25 def review? type == "review" end |