Allow specifying the tenant in budget tasks

The `budgets📧selected` and `budgets📧unselected` tasks are
supposed to be run manually because they only make sense at a specific
point during the life of a budget.

However, they would only run on the default tenant, and it was
impossible to run them on a different tenant.

So we're introducing an argument in the rake task accepting the name of
the tenant whose users we want to send emails to.
This commit is contained in:
Javi Martín
2022-10-08 21:51:18 +02:00
parent 796214528e
commit fe9463cb5f
2 changed files with 32 additions and 4 deletions

View File

@@ -1,13 +1,13 @@
namespace :budgets do
namespace :email do
desc "Sends emails to authors of selected investments"
task selected: :environment do
Budget.current.email_selected
task :selected, [:tenant] => :environment do |_, args|
Tenant.switch(args[:tenant]) { Budget.current.email_selected }
end
desc "Sends emails to authors of unselected investments"
task unselected: :environment do
Budget.current.email_unselected
task :unselected, [:tenant] => :environment do |_, args|
Tenant.switch(args[:tenant]) { Budget.current.email_unselected }
end
end
end