1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-12 23:09:03 +01:00
fab-manager/app/services/statistics/cleaner_service.rb
2022-08-29 17:34:09 +02:00

21 lines
600 B
Ruby

# frozen_string_literal: true
# Clean the existing statistics
class Statistics::CleanerService
include Statistics::Concerns::HelpersConcern
class << self
def clean_stat(options = default_options)
client = Elasticsearch::Model.client
%w[Account Event Machine Project Subscription Training User Space].each do |o|
model = "Stats::#{o}".constantize
client.delete_by_query(
index: model.index_name,
type: model.document_type,
body: { query: { match: { date: format_date(options[:start_date]) } } }
)
end
end
end
end