Class: RailsPulse::CleanupService

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_pulse/cleanup_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCleanupService

Returns a new instance of CleanupService.



7
8
9
10
11
12
13
14
# File 'lib/rails_pulse/cleanup_service.rb', line 7

def initialize
  @config = RailsPulse.configuration
  @stats = {
    time_based: {},
    count_based: {},
    total_deleted: 0
  }
end

Class Method Details

.performObject



3
4
5
# File 'lib/rails_pulse/cleanup_service.rb', line 3

def self.perform
  new.perform
end

Instance Method Details

#performObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rails_pulse/cleanup_service.rb', line 16

def perform
  return unless cleanup_enabled?

  Rails.logger.info "[RailsPulse] Starting data cleanup..."

  perform_time_based_cleanup
  perform_count_based_cleanup

  log_cleanup_summary
  @stats
end