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