Skip to content

Instantly share code, notes, and snippets.

@camwest
Created October 25, 2011 17:47
Show Gist options
  • Save camwest/1313629 to your computer and use it in GitHub Desktop.
Save camwest/1313629 to your computer and use it in GitHub Desktop.
Who's behind sample script
log = Logger.new("/tmp/whos_behind.log")
log.info "Producer Number, Full Name, Email, Party Key, Agency Status, Personal Status, Completed Elective Points, Outstanding Essentials"
Certification.where(["code IN(?)", [:agent, :lsp]]).each do |certification|
certification.users.limit(10).each do |user|
if user.party_type == 'Agent'
organization = user.organization
agency_status = organization.status
else
agency_status = '-'
end
full_name = user.name
email = user.email
party_key = user.alternate_ids.select("token, CHAR_LENGTH(token) token_length").having("token_length = 10").collect(&:token).join(", ")
completed_elective_points = user.certification.points_for(user.id, user.completions)
remaining_essentials = user.certification.send(:essentials_remaining, user.id, user.completions)
personal_status = user.certification.status(user.id, user.completions)
user.accounts.each do |account|
producer_number = account.subdomain[8..account.subdomain.length]
log.info "#{producer_number}, #{full_name}, #{email}, #{party_key}, #{agency_status}, #{personal_status}, #{completed_elective_points}, #{remaining_essentials}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment