Class: Task

Inherits:
MLS::Model show all
Defined in:
lib/mls/models/task.rb

Instance Method Summary collapse

Instance Method Details

#crawl?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/mls/models/task.rb', line 37

def crawl?
  type == "crawl"
end

#durationObject



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

Returns:

  • (Boolean)


29
30
31
# File 'lib/mls/models/task.rb', line 29

def fix?
  type == "fix"
end

#for_source?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/mls/models/task.rb', line 17

def for_source?
  subject_type == "Source"
end

#for_task?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/mls/models/task.rb', line 21

def for_task?
  subject_type == "Task"
end

#parse?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/mls/models/task.rb', line 33

def parse?
  type == "parse"
end

#pauseObject



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

Returns:

  • (Boolean)


41
42
43
# File 'lib/mls/models/task.rb', line 41

def paused?
  status == 'paused'
end

#resumeObject



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

Returns:

  • (Boolean)


25
26
27
# File 'lib/mls/models/task.rb', line 25

def review?
  type == "review"
end