Skip to content

Commit

Permalink
Merge pull request #211 from Ches-ctrl/2024-07-04-ai-and-form-fields
Browse files Browse the repository at this point in the history
2024 07 04 ai and form fields
  • Loading branch information
Ches-ctrl committed Jul 15, 2024
2 parents e20a6ca + 136c938 commit a0bb1d4
Show file tree
Hide file tree
Showing 16 changed files with 473 additions and 492 deletions.
2 changes: 1 addition & 1 deletion app/assets/builds/tailwind.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions app/jobs/importer/get_api_fields_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Importer
class GetApiFieldsJob < ApplicationJob
include Sidekiq::Status::Worker

queue_as :importers
sidekiq_options retry: false

def perform(job)
Importer::GetApiFields.call(job)
end
end
end
259 changes: 1 addition & 258 deletions app/models/concerns/ats/greenhouse/application_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,265 +2,8 @@ module Ats
module Greenhouse
module ApplicationFields
def get_application_criteria(job, _data)
job.application_criteria = CORE_FIELDS
# GetForm.perform
job.application_criteria = Importer::GetApiFields.call
end

CORE_FIELDS = {
first_name: {
interaction: :input,
locators: 'first_name',
required: true,
label: 'First Name',
core_field: true
},
last_name: {
interaction: :input,
locators: 'last_name',
required: true,
label: 'Last Name',
core_field: true
},
email: {
interaction: :input,
locators: 'email',
required: true,
label: 'Email',
core_field: true
},
phone_number: {
interaction: :input,
locators: 'phone',
required: true,
label: 'Phone',
core_field: true
},
city: {
interaction: :input,
locators: 'location',
required: false,
label: 'Location (City)',
core_field: true
},
resume: {
interaction: :upload,
locators: 'button[aria-describedby="resume-allowable-file-types"',
required: true,
label: 'Resume/CV',
core_field: true
},
cover_letter_: {
interaction: :upload,
locators: 'button[aria-describedby="cover_letter-allowable-file-types"]',
required: true,
label: 'Cover Letter',
core_field: true
}
}

ADDITIONAL_FIELDS = {
school: {
interaction: :select,
locators: 's2id_education_school_name_0',
required: true,
placeholder: 'Select a School',
data_url: 'https://boards-api.greenhouse.io/v1/boards/phonepe/education/schools',
label: 'School',
core_field: false
},
degree: {
interaction: :select,
locators: 's2id_education_degree_0',
required: false,
label: 'Degree',
core_field: false
},
discipline: {
interaction: :select,
locators: 's2id_education_discipline_0',
required: false,
label: 'Discipline',
core_field: false
},
ed_start_date_year: {
interaction: :input,
locators: 'job_application[educations][][start_date][year]',
required: true,
label: 'Education Start Date Year',
core_field: false
},
ed_end_date_year: {
interaction: :input,
locators: 'job_application[educations][][end_date][year]',
required: true,
label: 'Education End Date Year',
core_field: false
},
company_name: {
interaction: :input,
locators: 'job_application[employments][][company_name]',
required: true,
label: 'Company Name',
core_field: false
},
title: {
interaction: :input,
locators: 'job_application[employments][][title]',
required: true,
label: 'Title',
core_field: false
},
emp_start_date_month: {
interaction: :input,
locators: 'job_application[employments][][start_date][month]',
required: true,
label: 'Employment Start Date Month',
core_field: false
},
emp_start_date_year: {
interaction: :input,
locators: 'job_application[employments][][start_date][year]',
required: true,
label: 'Employment Start Date Year',
core_field: false
},
emp_end_date_month: {
interaction: :input,
locators: 'job_application[employments][][end_date][month]',
required: true,
label: 'Employment End Date Month',
core_field: false
},
emp_end_date_year: {
interaction: :input,
locators: 'job_application[employments][][end_date][year]',
required: true,
label: 'Employment End Date Year',
core_field: false
},
linkedin_profile: {
interaction: :input,
locators: 'input[autocomplete="custom-question-linkedin-profile"]',
required: false,
label: 'LinkedIn Profile',
core_field: false
},
personal_website: {
interaction: :input,
locators: 'input[autocomplete="custom-question-website"], input[autocomplete="custom-question-portfolio-linkwebsite"]',
required: false,
label: 'Personal Website',
core_field: false
},
gender: {
interaction: :input,
locators: 'input[autocomplete="custom-question-website"], input[autocomplete="custom-question-portfolio-linkwebsite"]',
required: false,
label: 'Gender',
core_field: false
}
# location_click: {
# interaction: :listbox,
# locators: 'ul#location_autocomplete-items-popup'
# },

# heard_from: {
# interaction: :input,
# locators: 'input[autocomplete="custom-question-how-did-you-hear-about-this-job"]'
# },
# require_visa?: {
# interaction: :input,
# locators: 'textarea[autocomplete="custom-question-would-you-need-sponsorship-to-work-in-the-uk-"]'
# },
}

DEGREE_OPTIONS = [
"High School",
"Associate's Degree",
"Bachelor's Degree",
"Master's Degree",
"Master of Business Administration (M.B.A.)",
"Juris Doctor (J.D.)",
"Doctor of Medicine (M.D.)",
"Doctor of Philosophy (Ph.D.)",
"Engineer's Degree",
"Other"
]

DISCIPLINE_OPTIONS = [
"Accounting",
"African Studies",
"Agriculture",
"Anthropology",
"Applied Health Services",
"Architecture",
"Art",
"Asian Studies",
"Biology",
"Business",
"Business Administration",
"Chemistry",
"Classical Languages",
"Communications &amp; Film",
"Computer Science",
"Dentistry",
"Developing Nations",
"Discipline Unknown",
"Earth Sciences",
"Economics",
"Education",
"Electronics",
"Engineering",
"English Studies",
"Environmental Studies",
"European Studies",
"Fashion",
"Finance",
"Fine Arts",
"General Studies",
"Health Services",
"History",
"Human Resources Management",
"Humanities",
"Industrial Arts &amp; Carpentry",
"Information Systems",
"International Relations",
"Journalism",
"Languages",
"Latin American Studies",
"Law",
"Linguistics",
"Manufacturing &amp; Mechanics",
"Mathematics",
"Medicine",
"Middle Eastern Studies",
"Naval Science",
"North American Studies",
"Nuclear Technics",
"Operations Research &amp; Strategy",
"Organizational Theory",
"Philosophy",
"Physical Education",
"Physical Sciences",
"Physics",
"Political Science",
"Psychology",
"Public Policy",
"Public Service",
"Religious Studies",
"Russian &amp; Soviet Studies",
"Scandinavian Studies",
"Science",
"Slavic Studies",
"Social Science",
"Social Sciences",
"Sociology",
"Speech",
"Statistics &amp; Decision Theory",
"Urban Studies",
"Veterinary Medicine",
"Other"
]
end
end
end
4 changes: 4 additions & 0 deletions app/services/faraday_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ def stream_xml_data(body)
def log_error(message)
Rails.logger.error(message)
end

def pretty_generate(json)
JSON.pretty_generate(json)
end
end
56 changes: 56 additions & 0 deletions app/services/importer/get_api_fields.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module Importer
# Core class for getting form fields directly from the API
# Splits based on category of fields - main, custom, demographic, eeoc
# Known Issues - Building the checkbox logic for the data_compliance section
# Allowable file types (Greenhouse): (File types: pdf, doc, docx, txt, rtf)
# NB. Must include all params to get additional fields from the API
class GetApiFields < ApplicationTask
include FaradayHelpers

def initialize
# @job = job
# @url = @job.api_url
@url = "https://boards-api.greenhouse.io/v1/boards/cleoai/jobs/4628944002"
# @url = "https://boards-api.greenhouse.io/v1/boards/cleoai/jobs/7301308002"
# @url = "https://boards-api.greenhouse.io/v1/boards/monzo/jobs/6076740"
# @url = "https://boards-api.greenhouse.io/v1/boards/axios/jobs/6009256"
# @url = "https://boards-api.greenhouse.io/v1/boards/11fs/jobs/4060453101"
# @url = "https://boards-api.greenhouse.io/v1/boards/forter/jobs/7259821002"
# @url = "https://boards-api.greenhouse.io/v1/boards/cleoai/jobs/4628944002"
@url += "?questions=true&location_questions=true&demographic_questions=true&&compliance=true&pay_transparency=true"
# @ats_sections = %w[main_fields custom_fields demographic_questions eeoc_fields data_compliance security_code_fields]
@fields = {}
@errors = false
end

def call
return unless processable

process
rescue StandardError => e
Rails.logger.error "Error running GetFormFields: #{e.message}"
nil
end

private

def processable
@url # && @job
end

def process
p "Hello from GetApiFields!"

json = fetch_json(@url)
return unless json

@fields['main_fields'] = json['questions']
@fields['demographic_questions'] = json['demographic_questions']
@fields['location_questions'] = json['location_questions']
@fields['data_compliance'] = json['data_compliance']

puts pretty_generate(@fields)
@fields
end
end
end
Loading

0 comments on commit a0bb1d4

Please sign in to comment.