Skip to content

Commit

Permalink
Merge branch 'md/usage-report' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
tvcam committed Aug 24, 2023
2 parents f3929dc + 000f9dc commit d8e9d9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
rake 'ngo_usage_report:generate', output: 'log/whenever.log'
# rake 'staff_monthly_report:generate', output: 'log/whenever.log'
end

every :month, at: '2:00 am' do
rake 'usage_report:build_latest', output: 'log/usage_report.log'
end
12 changes: 12 additions & 0 deletions lib/tasks/rebuild_usage_report.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ namespace :usage_report do
end
end
end

desc "Build latest usage report"
task :build_latest, [:short_name] => :environment do |task, args|
if args.short_name
org = Organization.find_by!(short_name: args.short_name)
UsageReportBuilder.call(org, 1.month.ago.month, 1.month.ago.year)
else
Organization.without_shared.each do |org|
UsageReportBuilder.call(org, 1.month.ago.month, 1.month.ago.year)
end
end
end
end

def rebuild_report(org)
Expand Down

0 comments on commit d8e9d9d

Please sign in to comment.