Skip to content

Instantly share code, notes, and snippets.

@ahmdrefat
Created October 21, 2012 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmdrefat/3926332 to your computer and use it in GitHub Desktop.
Save ahmdrefat/3926332 to your computer and use it in GitHub Desktop.
def get_positions
positions = Position.find_all_by_full_profile_id(current_user.full_profile.id)
if positions.empty?
client = get_client
positions = client.profile(:fields => [:positions]).positions.all
positions.each do |p|
if p.is_current == "true"
Position.create(
title: p.title,
summary: p.summary,
start_date: Date.parse("1/#{p.start_date.month ? p.start_date.month : 1}/#{p.start_date.year}"),
end_date: Date.parse("1/#{p.end_date.month ? p.end_date.month : 1}/#{p.end_date.year}"),
is_current: p.is_current,
company: p.company.name,
full_profile_id: current_user.full_profile.id)
else
Position.create(
title: p.title,
summary: p.summary,
start_date: Date.parse("1/#{p.start_date.month ? p.start_date.month : 1}/#{p.start_date.year}"),
is_current: p.is_current,
company: p.company.name,
full_profile_id: current_user.full_profile.id)
end
end
current_user.full_profile.positions
else
positions
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment