app/models/task.rb
def missed
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
    if @last_completion
      hours_since = (Time.now - @last_completion.created_at)/3600
      hours_since_scheduled = (Time.now)
      if self.done
        return false
      elsif (self.kind == "Hourly") && (hours_since >= (1 + (location.department.department_config.task_leniency)/60)) #if a task has not been done for an hour after it has been done, it is considered missed
        return true
      elsif (self.kind == "Daily") && (self.late_time)
        return true
      elsif (self.kind == "Weekly") && (self.delayed_day || (self.late_time && self.right_day))
        return true
      else
        return false
      end
    else
      return false
    end
  end
#missed tasks are tasks that need doing that have not been done past a certain time
missed tasks are tasks that need doing that have not been done past a certain time
missed tasks are tasks that need doing that have not been done past a certain time
def missed
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last 
    if @last_completion
      hours_since = (Time.now - @last_completion.created_at)/3600
      hours_since_scheduled = (Time.now)
      if self.done
        return false
      elsif (self.kind == "Hourly") && (hours_since >= (1 + (location.department.department_config.task_leniency)/60)) 
        return true
      elsif (self.kind == "Daily") && (self.late_time)
        return true
      elsif (self.kind == "Weekly") && (self.delayed_day || (self.late_time && self.right_day))
        return true
      else
        return false
      end
    else
      return false
    end
  end
def missed @last_completion = ShiftsTask . find_all_by_task_id ( self . id ) . select { | st | st . task_id == self . id } . last if @last_completion hours_since = ( Time . now - @last_completion . created_at ) / 3600 hours_since_scheduled = ( Time . now ) if self . done return false elsif ( self . kind == "Hourly" ) && ( hours_since >= ( 1 + ( location . department . department_config . task_leniency ) / 60 ) ) return true elsif ( self . kind == "Daily" ) && ( self . late_time ) return true elsif ( self . kind == "Weekly" ) && ( self . delayed_day || ( self . late_time && self . right_day ) ) return true else return false end else return false end end
missed tasks are tasks that need doing that have not been done past a certain time
missed tasks are tasks that need doing that have not been done past a certain time
#use find method #if a task has not been done for an hour after it has been done, it is considered missed