mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
add a rake task for regenerate statistics
This commit is contained in:
parent
524b2c97bb
commit
e296653157
@ -108,5 +108,23 @@ namespace :fablab do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'regenerate statistics'
|
||||
task :regenerate_statistics, %i[year month] => :environment do |_task, args|
|
||||
return unless Setting.get('statistics_module')
|
||||
|
||||
yesterday = 1.day.ago
|
||||
year = args.year || yesterday.year
|
||||
month = args.month || yesterday.month
|
||||
start_date = Time.zone.local(year.to_i, month.to_i, 1)
|
||||
end_date = yesterday.end_of_day
|
||||
puts "-> Start regenerate statistics between #{I18n.l start_date, format: :long} and " \
|
||||
"#{I18n.l end_date, format: :long}"
|
||||
StatisticService.new.generate_statistic(
|
||||
start_date: start_date,
|
||||
end_date: end_date
|
||||
)
|
||||
puts '-> Done'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user