-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
6 deletions.
There are no files selected for viewing
20 changes: 14 additions & 6 deletions
20
lib/tasks/accounts/create_leads_for_instructors_not_sent_to_sf.rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
namespace :accounts do | ||
desc 'Create leads for faculty verified by SheerID and never sent to Salesforce' | ||
# rake accounts:create_leads_for_instructors_not_sent_to_sf | ||
# To be run to fix users that were not sent to SF during bug from 26Jan22 to xxFeb22 (hotfix release date) | ||
task :create_leads_for_instructors_not_sent_to_sf, [:day] => [:environment] do |t, args| | ||
# get all the instructors that don't have lead or contact ids | ||
users = User.where(salesforce_contact_id: nil, salesforce_lead_id: nil, role: :instructor, state: :activated).or(User.where.not(sheerid_verification_id: nil)) | ||
users.each { |user| | ||
Newflow::CreateSalesforceLead.perform_later(user: user) | ||
} | ||
# get all the instructors that don't have lead or contact ids and have a complete profile | ||
users = User.where(salesforce_contact_id: nil, salesforce_lead_id: nil, role: :instructor, is_profile_complete: true) | ||
|
||
users.each do |user| | ||
lead = OpenStax::Salesforce::Remote::Lead.select(:id, :verification_status).find_by(accounts_uuid: user.uuid) | ||
|
||
if lead.nil? | ||
Newflow::CreateOrUpdateSalesforceLead.call(user: user) | ||
else | ||
# set the lead id, this will update their status in UpdateUserLeadInfo | ||
user.salesforce_lead_id = lead.id | ||
user.save | ||
end | ||
end | ||
end | ||
end |