Created
March 3, 2015 13:46
-
-
Save nightfox/033b44236b9c54867686 to your computer and use it in GitHub Desktop.
Invite gist
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
::Recruit::TestInvite.where('created_at > ?', Time.now - 7.days).each do |test_invite| | |
test_invite.candidates_data.each do |candidate| | |
candidate.symbolize_keys! | |
next unless candidate[:name].presence | |
test_user = ::Recruit::TestUser.where(tid:test_invite.tid, email: candidate[:email]).last | |
next if test_user.blank? | |
orig_metadata = test_user['metadata'] | |
if orig_metadata.blank? | |
new_metadata = {} | |
else | |
begin | |
new_metadata = JSON.parse(orig_metadata || '{}') | |
rescue JSON::ParserError | |
new_metadata = {} | |
end | |
end | |
new_metadata['name'] = candidate[:name] | |
test_user['metadata'] = new_metadata.to_json | |
test_user.save | |
candidate_model = test_user.candidate | |
candidate_model.name = candidate[:name] if candidate_model.name.blank? | |
candidate_model.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment