mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-24 13:52:21 +01:00
fe419f295a
The date of the statistics data was using the date of the regenerate command parameter. This was ok for the nightly builds but definitly not for bulk regeneration
29 lines
803 B
Ruby
29 lines
803 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: {
|
|
terms: {
|
|
date: (to_date(options[:start_date]).to_date..to_date(options[:end_date]).to_date)
|
|
.to_a
|
|
.map { |d| format_date(d) }
|
|
}
|
|
}
|
|
}
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|