Class: SourceMonitor::Items::RetentionStrategies::SoftDelete
- Inherits:
-
Object
- Object
- SourceMonitor::Items::RetentionStrategies::SoftDelete
- Defined in:
- lib/source_monitor/items/retention_strategies/soft_delete.rb
Instance Method Summary collapse
- #apply(batch:, now: Time.current) ⇒ Object
-
#initialize(source:) ⇒ SoftDelete
constructor
A new instance of SoftDelete.
Constructor Details
#initialize(source:) ⇒ SoftDelete
Returns a new instance of SoftDelete.
7 8 9 |
# File 'lib/source_monitor/items/retention_strategies/soft_delete.rb', line 7 def initialize(source:) @source = source end |
Instance Method Details
#apply(batch:, now: Time.current) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/source_monitor/items/retention_strategies/soft_delete.rb', line 11 def apply(batch:, now: Time.current) ids = Array(batch.pluck(:id)) return 0 if ids.empty? = (now) # Use with_deleted to update items that may already be marked as deleted SourceMonitor::Item.with_deleted.where(id: ids).update_all( deleted_at: , updated_at: ) adjust_source_counter(ids.length) ids.length end |