Class: SolidApm::CleanupService
- Inherits:
-
Object
- Object
- SolidApm::CleanupService
- Defined in:
- lib/solid_apm/cleanup_service.rb
Constant Summary collapse
- DURATION_PATTERN =
Regex to match safe time expressions like “1.week.ago”, “2.months.ago”, etc.
/\A(\d+)\.(second|minute|hour|day|week|month|year)s?\.ago\z/.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(older_than: '1.month.ago') ⇒ CleanupService
constructor
A new instance of CleanupService.
Constructor Details
#initialize(older_than: '1.month.ago') ⇒ CleanupService
Returns a new instance of CleanupService.
7 8 9 |
# File 'lib/solid_apm/cleanup_service.rb', line 7 def initialize(older_than: '1.month.ago') @older_than = older_than end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/solid_apm/cleanup_service.rb', line 11 def call cutoff_time = parse_time_expression(@older_than) deleted_count = Transaction.where(timestamp: ...cutoff_time).destroy_all.size { cutoff_time: cutoff_time, deleted_count: deleted_count, older_than: @older_than } end |