2 changed files with 111 additions and 28 deletions
@ -1,37 +1,118 @@ |
|||||
json.user do |
user = @user |
||||
json.id @user.id |
split_list = lambda do |value| |
||||
json.name @user.name |
value.to_s.split(/[;,]/).map { |item| item.strip }.reject(&:blank?) |
||||
json.title @user.title |
end |
||||
|
|
||||
|
parse_period = lambda do |period| |
||||
|
years = period.to_s.scan(/\b(19\d{2}|20\d{2})\b/).flatten |
||||
|
return [nil, nil] if years.empty? |
||||
|
[years[0], years[1]] |
||||
|
end |
||||
|
|
||||
json.work_experiences @user.work_experiences.active do |work| |
normalize_url = lambda do |value| |
||||
# json.id work.id |
return nil if value.blank? |
||||
json.title work.title |
value.match?(/\Ahttps?:\/\//) ? value : "https://#{value}" |
||||
|
end |
||||
|
|
||||
json.organization work.employer |
profile_from = lambda do |value, network, base_url| |
||||
|
return nil if value.blank? |
||||
|
|
||||
if work.technologies.present? |
if value.include?("/") || value.include?(".") |
||||
json.technologies work.technologies |
url = normalize_url.call(value) |
||||
|
username = url.to_s.split("/").last&.delete_prefix("@") |
||||
|
else |
||||
|
username = value.delete_prefix("@") |
||||
|
url = base_url.present? ? "#{base_url}/#{username}" : nil |
||||
|
end |
||||
|
|
||||
|
profile = { "network" => network } |
||||
|
profile["username"] = username if username.present? |
||||
|
profile["url"] = url if url.present? |
||||
|
profile |
||||
|
end |
||||
|
|
||||
|
json.basics do |
||||
|
json.name user.name if user.name.present? |
||||
|
json.label user.title if user.title.present? |
||||
|
json.email user.email if user.email.present? |
||||
|
json.phone user.phone if user.phone.present? |
||||
|
json.summary user.objective if user.objective.present? |
||||
|
|
||||
|
if user.address.present? |
||||
|
json.location do |
||||
|
json.address user.address |
||||
end |
end |
||||
json.period work.period |
end |
||||
|
|
||||
|
primary_url = user.other_page_url.presence || user.linkedin.presence || user.github.presence |
||||
|
url = normalize_url.call(primary_url) |
||||
|
json.url url if url.present? |
||||
|
|
||||
|
profiles = [] |
||||
|
profiles << profile_from.call(user.linkedin, "LinkedIn", "https://www.linkedin.com/in") |
||||
|
profiles << profile_from.call(user.github, "GitHub", "https://github.com") |
||||
|
profiles << profile_from.call(user.other_page_url, "Website", nil) |
||||
|
profiles.compact! |
||||
|
json.profiles profiles if profiles.any? |
||||
|
end |
||||
|
|
||||
json.responsibilities do |
if user.work_experiences.active.any? |
||||
json.array! work.items_csv&.split(";") |
json.work user.work_experiences.active do |work_entry| |
||||
|
start_date, end_date = parse_period.call(work_entry.period) |
||||
|
highlights = split_list.call(work_entry.items_csv) |
||||
|
technologies = split_list.call(work_entry.technologies) |
||||
|
highlights << "Technologies: #{technologies.join(', ')}" if technologies.any? |
||||
|
|
||||
|
summary = work_entry.achivements.presence |
||||
|
summary = work_entry.period.presence if summary.blank? && start_date.blank? && end_date.blank? |
||||
|
|
||||
|
json.name work_entry.employer if work_entry.employer.present? |
||||
|
json.position work_entry.title if work_entry.title.present? |
||||
|
json.summary summary if summary.present? |
||||
|
json.highlights highlights if highlights.any? |
||||
|
json.startDate start_date if start_date.present? |
||||
|
json.endDate end_date if end_date.present? |
||||
|
|
||||
|
if start_date.blank? && end_date.blank? && work_entry.reference_date.present? |
||||
|
json.endDate work_entry.reference_date.iso8601 |
||||
end |
end |
||||
end |
end |
||||
|
end |
||||
|
|
||||
|
if user.education_entries.active.any? |
||||
|
json.education user.education_entries.active do |education_entry| |
||||
|
start_date, end_date = parse_period.call(education_entry.period) |
||||
|
|
||||
|
study_type = education_entry.title |
||||
|
area = nil |
||||
|
if study_type.present? && study_type.match?(/\s+in\s+/i) |
||||
|
study_type, area = study_type.split(/\s+in\s+/i, 2) |
||||
|
end |
||||
|
|
||||
|
courses = split_list.call(education_entry.items_csv) |
||||
|
|
||||
|
json.institution education_entry.institution if education_entry.institution.present? |
||||
|
json.studyType study_type if study_type.present? |
||||
|
json.area area if area.present? |
||||
|
json.courses courses if courses.any? |
||||
|
json.startDate start_date if start_date.present? |
||||
|
json.endDate end_date if end_date.present? |
||||
|
|
||||
json.skills @user.skills.active do |skill| |
if start_date.blank? && end_date.blank? && education_entry.reference_date.present? |
||||
# json.id skill.id |
json.endDate education_entry.reference_date.iso8601 |
||||
json.title skill.title |
end |
||||
json.detail skill.detail |
|
||||
end |
end |
||||
|
end |
||||
|
|
||||
|
if user.skills.active.any? |
||||
|
json.skills user.skills.active do |skill| |
||||
|
keywords = split_list.call(skill.detail) |
||||
|
|
||||
json.education_entries @user.education_entries.active do |edu| |
json.name skill.title if skill.title.present? |
||||
json.institution edu.institution |
if keywords.any? |
||||
json.title edu.title |
json.keywords keywords |
||||
json.location edu.location |
elsif skill.detail.present? |
||||
json.period edu.period |
json.level skill.detail |
||||
json.items do |
|
||||
json.array! edu.items_csv&.split(";") |
|
||||
end |
end |
||||
end |
end |
||||
end |
end |
||||
|
|||||
Loading…
Reference in new issue