Sha256: f99d191c71bbf49b198b1dceaca8718b6e829e91c4135138c7d8f57e13fe9cc9

Contents?: true

Size: 549 Bytes

Versions: 11

Compression:

Stored size: 549 Bytes

Contents

class CleanupSuggestedHouseholdsJob < Struct.new(:individual_id)

  def matches(id)
    SuggestedHousehold.where("ids like '%,?,%' or ids like '%,?' or ids like '?,%'", id, id, id)
  end

  def perform
    matches(self.individual_id).each do |suggestion|
      ids = suggestion.ids.split(',')
      if ids.count == 2 # Only one other individual in the household, safe to destroy
        suggestion.destroy
      else
        suggestion.update_attributes(:ids => ids.reject { |i| i.to_s == individual_id.to_s }.join(','))
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre4 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.3.0.pre3 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.3.0.pre2 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.3.0.pre1 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0.beta.1 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0.alpha.2 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0.alpha.1 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0.pre.27 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0.pre.26 app/models/job/cleanup_suggested_households_job.rb
artfully_ose-1.2.0.pre.24 app/models/job/cleanup_suggested_households_job.rb