Skip to content

Commit

Permalink
Merge pull request #222 from Ches-ctrl/24/07/24_apply_to_all
Browse files Browse the repository at this point in the history
New Greenhouse FormFiller can answer multi_select and demographic que…
  • Loading branch information
patanj101 committed Jul 30, 2024
2 parents f78356c + b9ea35d commit a447804
Show file tree
Hide file tree
Showing 32 changed files with 2,203 additions and 2,558 deletions.
6 changes: 4 additions & 2 deletions app/models/application_question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ def initialize(questions_params)
# == Scopes ===============================================================
# == Validations ==========================================================

# nb: attribute can be nil, so safe navigation operator is necessary with #include?

def boolean? = type.eql?("boolean")
def checkbox? = type.eql?("checkbox")
def cover_letter? = attribute.include?("cover_letter")
def cover_letter? = attribute&.include?("cover_letter")
def input? = type.eql?("input") || type.eql?("education_input")
def linkedin_related? = attribute.include?('linkedin')
def linkedin_related? = attribute&.include?('linkedin')
def multi_select? = type.eql?("multi_select")
def radiogroup? = type.eql?("radiogroup")
def resume? = attribute.eql?("resume")
Expand Down
198 changes: 2 additions & 196 deletions app/models/concerns/ats/bamboohr/application_fields.rb
Original file line number Diff line number Diff line change
@@ -1,203 +1,9 @@
module Ats
module Bamboohr
module ApplicationFields
def get_application_question_set(_job, _data)
p "Getting BambooHR application criteria"

# TODO : implement new application_question_structure structure
# job.application_question_set = build_application_question_set_from(data['formFields'])
[]
def get_application_question_set(job, data)
Importer::GetBambooFields.call(job, data)
end

private

def build_application_question_set_from(fields)
attributes = {}

fields.each do |locator, details|
field = details.instance_of?(Array) ? build_additional_field(details) : build_core_field(locator, details)
attributes.merge!(field)
rescue StandardError => e
p "Error building application criteria: #{e.message}"
{}
end

return attributes
end

def build_core_field(locator, data)
name, details = CORE_FIELDS.find { |_, attributes| attributes[:locators] == locator }
{
name => details.merge(
required: data['isRequired'],
options: data['options']&.map { |option| option['text'] }
).compact
}
end

def build_additional_field(data)
data.inject({}) do |question_set, field|
name, interaction, options = fetch_field_attributes(field)
question_set.merge!(
name => {
interaction:,
label: field['question'],
locators: field['id'],
required: field['isRequired'],
options:
}.compact
)
end
end

def fetch_field_attributes(field)
name = field['question'].downcase.gsub(' ', '_').gsub(/[^a-z0-9_-]/, '')
options = field['options']&.map { |option| option['text'] } unless field['options'].blank?
interaction = FIELD_TYPES[field['type']]
if interaction == :boolean
options ||= ['Yes', 'No']
interaction = :select
end
[name, interaction, options]
end

FIELD_TYPES = {
'short' => :input,
'long' => :input,
'checkbox' => :boolean,
'yes_no' => :boolean
}

CORE_FIELDS = {
first_name: {
interaction: :input,
locators: 'firstName',
label: 'First Name',
core_field: true
},
last_name: {
interaction: :input,
locators: 'lastName',
label: 'Last Name',
core_field: true
},
email: {
interaction: :input,
locators: 'email',
label: 'Email',
core_field: true
},
phone_number: {
interaction: :input,
locators: 'phone',
label: 'Phone',
core_field: true
},
address: {
interaction: :input,
locators: 'streetAddress',
label: 'Address',
core_field: true
},
city: {
interaction: :input,
locators: 'city',
label: 'City',
core_field: true
},
state: {
interaction: :select,
locators: 'state',
label: 'State',
core_field: true
},
post_code: {
interaction: :input,
locators: 'zip',
label: 'ZIP',
core_field: true
},
country: {
interaction: :input,
locators: 'countryId',
label: 'Country',
core_field: true
},
website_url: {
interaction: :input,
locators: 'websiteUrl',
label: 'Website, Blog, or Portfolio',
core_field: true
},
linkedin_url: {
interaction: :input,
locators: 'linkedinUrl',
label: 'LinkedIn Profile URL',
core_field: true
},
cover_letter: {
interaction: :upload,
locators: 'coverLetterFileId',
label: 'Cover Letter',
core_field: true
},
resume: {
interaction: :upload,
locators: 'resumeFileId',
label: 'Resume',
core_field: true
},
education_level: {
interaction: :select,
locators: 'educationLevelId',
label: 'Highest Education Obtained',
core_field: true
},
education_school: {
interaction: :input,
locators: 'educationInstitutionName',
label: 'College/University',
core_field: true
},
date_available: {
interaction: :date,
locators: 'dateAvailable',
label: 'Date Available',
core_field: true
},
desired_pay: {
interaction: :input,
locators: 'desiredPay',
label: 'Desired Pay',
core_field: true
},
referred_by: {
interaction: :input,
locators: 'referredBy',
label: 'Who referred you for this position?',
core_field: true
},
gender: {
interaction: :select,
locators: 'genderId',
label: 'Gender'
},
ethnicity: {
interaction: :select,
locators: 'ethnicityId',
label: 'Ethnicity'
},
disability: {
interaction: :select,
locators: 'disabilityId',
label: 'Disability'
},
veteran_status: {
interaction: :select,
locators: 'veteranStatusId',
label: 'Veteran Status'
}
}
end
end
end
4 changes: 1 addition & 3 deletions app/services/applier/ashby_form_filler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def sample_payload
{
user_fullname: 'John Smith',
apply_url: 'https://jobs.ashbyhq.com/lightdash/9efa292a-cc34-4388-90a2-2bed5126ace4',
form_locator: '#form',
fields: [
{
locator: '_systemfield_name',
Expand Down Expand Up @@ -88,7 +87,6 @@ def multiverse_payload
{
user_fullname: 'Jean-Jacques Rousseau',
apply_url: 'https://jobs.ashbyhq.com/multiverse/69afde82-dad8-4923-937e-a8d7f0551db4',
form_locator: '#form',
fields: [
{
locator: '_systemfield_name',
Expand All @@ -103,7 +101,7 @@ def multiverse_payload
{
locator: '_systemfield_resume',
interaction: :upload,
value: File.open('public/Obretetskiy_cv.pdf')
value: 'https://res.cloudinary.com/dzpupuayh/image/upload/v1/development/nd4p85sryuu40oz77n0bhs29b2sz.pdf?_a=BACCd2Bn'
},
{
locator: '1e68a3c6-1709-40e3-ad14-379c7f5bb56d',
Expand Down
Loading

0 comments on commit a447804

Please sign in to comment.