app/models/observation.rb
#
# Update the user's lists with changes to this observation's taxon
#
# If the observation is the last_observation in any of the user's lists,
# then the last_observation should be reset to another observation.
#
Update the user's lists with changes to this observation's taxon
If the observation is the last_observation in any of the user's lists,
then the last_observation should be reset to another observation.
Update the user ' s lists with changes to this observation ' s taxon If the observation is the last_observation in any of the user ' s lists then the last_observation should be reset to another observation .
def refresh_lists
    return true if skip_refresh_lists
    return true unless taxon_id_changed? || quality_grade_changed?
    target_taxa = [
      taxon, 
      Taxon.find_by_id(@old_observation_taxon_id)
    ].compact.uniq
    return true if target_taxa.empty?
    unless Delayed::Job.where("handler LIKE '%ProjectList%refresh_with_observation% #{id}\n%'").exists?
      ProjectList.delay(:priority => USER_INTEGRITY_PRIORITY, :queue => "slow").refresh_with_observation(id, :taxon_id => taxon_id, 
        :taxon_id_was => taxon_id_was, :user_id => user_id, :created_at => created_at)
    end
    return true unless taxon_id_changed?
    unless Delayed::Job.where("handler LIKE '%''List%refresh_with_observation% #{id}\n%'").exists?
      List.delay(:priority => USER_INTEGRITY_PRIORITY).refresh_with_observation(id, :taxon_id => taxon_id, 
        :taxon_id_was => taxon_id_was, :user_id => user_id, :created_at => created_at,
        :skip_subclasses => true)
    end
    unless Delayed::Job.where("handler LIKE '%LifeList%refresh_with_observation% #{id}\n%'").exists?
      LifeList.delay(:priority => USER_INTEGRITY_PRIORITY).refresh_with_observation(id, :taxon_id => taxon_id, 
        :taxon_id_was => taxon_id_was, :user_id => user_id, :created_at => created_at)
    end
    @old_observation_taxon_id = nil
    true
  end
def refresh_lists return true if skip_refresh_lists return true unless taxon_id_changed? || quality_grade_changed? target_taxa = [ taxon , Taxon . find_by_id ( @old_observation_taxon_id ) ] . compact . uniq return true if target_taxa . empty? unless Delayed :: Job . where ( "handler LIKE '%ProjectList%refresh_with_observation% #{id}\n%'" ) . exists? ProjectList . delay ( :priority => USER_INTEGRITY_PRIORITY , :queue => "slow" ) . refresh_with_observation ( id , :taxon_id => taxon_id , :taxon_id_was => taxon_id_was , :user_id => user_id , :created_at => created_at ) end return true unless taxon_id_changed? unless Delayed :: Job . where ( "handler LIKE '%''List%refresh_with_observation% #{id}\n%'" ) . exists? List . delay ( :priority => USER_INTEGRITY_PRIORITY ) . refresh_with_observation ( id , :taxon_id => taxon_id , :taxon_id_was => taxon_id_was , :user_id => user_id , :created_at => created_at , :skip_subclasses => true ) end unless Delayed :: Job . where ( "handler LIKE '%LifeList%refresh_with_observation% #{id}\n%'" ) . exists? LifeList . delay ( :priority => USER_INTEGRITY_PRIORITY ) . refresh_with_observation ( id , :taxon_id => taxon_id , :taxon_id_was => taxon_id_was , :user_id => user_id , :created_at => created_at ) end @old_observation_taxon_id = nil true end
Update the user's lists with changes to this observation's taxon
If the observation is the last_observation in any of the user's lists,
then the last_observation should be reset to another observation.
Update the user ' s lists with changes to this observation ' s taxon If the observation is the last_observation in any of the user ' s lists then the last_observation should be reset to another observation .
# Update the observation's current taxon and/or a previous one that was # just removed/changed # Don't refresh all the lists if nothing changed # Refreh the ProjectLists # Don't refresh LifeLists and Lists if only quality grade has changed # Reset the instance var so it doesn't linger around