Class: Card::Change
- Defined in:
- mod/01_history/lib/card/change.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.delete_actionless ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'mod/01_history/lib/card/change.rb', line 7 def delete_actionless joins( 'LEFT JOIN card_actions '\ 'ON card_changes.card_action_id = card_actions.id ' ).where( 'card_actions.id is null' ).find_in_batches do |group| # used to be .delete_all here, but that was failing on large dbs puts 'deleting batch of changes' where("id in (#{group.map(&:id).join ','})").delete_all end end |
.field_index(value) ⇒ Object
20 21 22 |
# File 'mod/01_history/lib/card/change.rb', line 20 def field_index value value.is_a?(Integer) ? value : TRACKED_FIELDS.index(value.to_s) end |
.find_by_field_name(value) ⇒ Object
24 25 26 |
# File 'mod/01_history/lib/card/change.rb', line 24 def find_by_field_name value find_by_field field_index(value) end |
Instance Method Details
#field ⇒ Object
33 34 35 |
# File 'mod/01_history/lib/card/change.rb', line 33 def field TRACKED_FIELDS[read_attribute(:field)] end |
#field=(value) ⇒ Object
29 30 31 |
# File 'mod/01_history/lib/card/change.rb', line 29 def field= value write_attribute(:field, TRACKED_FIELDS.index(value.to_s)) end |
#find_by_field_name(value) ⇒ Object
37 38 39 |
# File 'mod/01_history/lib/card/change.rb', line 37 def find_by_field_name value find_by_field self.class.field_index(value) end |