1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/services/statistics/builder_service.rb
Sylvain 2b80516177 (bug) unable to generate statistics
This bug is due to the refactoring of the statistics builder service,
in 2022 august. The default_options were not defined so the nightly
worker has no luck to run. The statistics may not have been built since
then, so a rebuild is required
2022-10-05 13:11:17 +02:00

27 lines
776 B
Ruby

# frozen_string_literal: true
# This will generate statistics indicators. Those will be saved in the ElasticSearch database
class Statistics::BuilderService
class << self
def generate_statistic(options = default_options)
# remove data exists
Statistics::CleanerService.clean_stat(options)
Statistics::Builders::SubscriptionsBuilderService.build(options)
Statistics::Builders::ReservationsBuilderService.build(options)
Statistics::Builders::MembersBuilderService.build(options)
Statistics::Builders::ProjectsBuilderService.build(options)
end
private
def default_options
yesterday = 1.day.ago
{
start_date: yesterday.beginning_of_day,
end_date: yesterday.end_of_day
}
end
end
end