app/models/concerns/iev_interfaces/task.rb
def update_status
    Rails.logger.info "#{self.class.name} ##{id}: update_status #{children.reload.map(&:status).inspect}"
    new_status = compute_new_status

    Rails.logger.info "#{self.class.name} ##{id}: status #{self.status} -> #{new_status}"
    return if self.status == new_status

    Rails.logger.info "#{self.class.name} ##{id}: status -> #{new_status}"

    attributes = {
      current_step: children.count, # !?
      status: new_status
    }

    if self.class.finished_statuses.include?(new_status)
      attributes[:ended_at] = Time.now
    end

    update attributes
    notify_state

    if respond_to?(:done!)
      Rails.logger.info "#{self.class.name} ##{id}: done!"
      done! (successful? || warning?)
    end
  end
# Compute and update status (only when it changes)
# Invokes done! method is defined and status is changed to finished
Compute and update status (only when it changes)
Invokes done. method is defined and status is changed to finished
Compute and update status ( only when it changes ) Invokes done . method is defined and status is changed to finished
def update_status
    Rails.logger.info "#{self.class.name} ##{id}: update_status #{children.reload.map(&:status).inspect}"
    new_status = compute_new_status
    Rails.logger.info "#{self.class.name} ##{id}: status #{self.status} -> #{new_status}"
    return if self.status == new_status
    Rails.logger.info "#{self.class.name} ##{id}: status -> #{new_status}"
    attributes = {
      current_step: children.count, 
      status: new_status
    }
    if self.class.finished_statuses.include?(new_status)
      attributes[:ended_at] = Time.now
    end
    update attributes
    notify_state
    if respond_to?(:done!)
      Rails.logger.info "#{self.class.name} ##{id}: done!"
      done! (successful? || warning?)
    end
  end
def update_status Rails . logger . info "#{self.class.name} ##{id}: update_status #{children.reload.map(&:status).inspect}" new_status = compute_new_status Rails . logger . info "#{self.class.name} ##{id}: status #{self.status} -> #{new_status}" return if self . status == new_status Rails . logger . info "#{self.class.name} ##{id}: status -> #{new_status}" attributes = { current_step : children . count , status : new_status } if self . class . finished_statuses . include? ( new_status ) attributes [ :ended_at ] = Time . now end update attributes notify_state if respond_to? ( :done! ) Rails . logger . info "#{self.class.name} ##{id}: done!" done! ( successful? || warning? ) end end
Compute and update status (only when it changes)
Invokes done!
Compute and update status ( only when it changes ) Invokes done!
# !?