Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Ches-ctrl/Cheddar into 2024-05-07…
Browse files Browse the repository at this point in the history
…-add-post-api

Merging master into add-post-api
  • Loading branch information
Ches-ctrl committed May 22, 2024
2 parents a7974c4 + 53fa635 commit 172f4c1
Show file tree
Hide file tree
Showing 131 changed files with 9,931 additions and 972 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

# Ignore master key for decrypting credentials and more.
/config/master.key

# Ignore .env file containing credentials.
.env*

Expand All @@ -41,7 +42,7 @@
.DS_Store
# .csv*

# Steven jetbrains files
# Ignore Jetbrains files
.idea/Cheddar.iml
.idea/misc.xml
.idea/modules.xml
Expand Down
40 changes: 40 additions & 0 deletions .slugignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# rubocop:disable all

# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore master key for decrypting credentials and more.
/config/master.key

# Ignore .env file containing credentials.
.env*

# Ignore .git file
.git

# Ignore test files
spec/**

# Ignore ignore files
.gitignore
.dockerignore

# Ignore yml files generated by VCR.
spec/fixtures/cassettes/ApplicantTrackingSystem/*.yml

# rubocop:enable all
16 changes: 9 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,17 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.1)
nokogiri (1.16.4-aarch64-linux)
nokogiri (1.16.5-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.4-arm-linux)
nokogiri (1.16.5-arm-linux)
racc (~> 1.4)
nokogiri (1.16.4-arm64-darwin)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86-linux)
nokogiri (1.16.5-x86-linux)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-darwin)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (8.2.0)
Expand Down Expand Up @@ -327,7 +327,8 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (4.2.1)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
Expand Down Expand Up @@ -424,6 +425,7 @@ GEM
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
strscan (3.1.0)
thor (1.3.1)
tilt (2.3.0)
timeout (0.4.1)
Expand Down
Binary file removed app/assets/images/ai_cartoon_smiley.png
Binary file not shown.
Binary file removed app/assets/images/ai_profile.png
Binary file not shown.
Binary file removed app/assets/images/cheddar_logo_text_blue.png
Binary file not shown.
Binary file removed app/assets/images/team/alejandro_avatar.png
Binary file not shown.
Binary file removed app/assets/images/team/charlie_avatar.png
Binary file not shown.
Binary file removed app/assets/images/team/chris_avatar.png
Binary file not shown.
Binary file removed app/assets/images/team/dan_avatar.png
Binary file not shown.
Binary file removed app/assets/images/team/ilya_avatar.png
Binary file not shown.
Binary file removed app/assets/images/team/jamie_avatar.png
Binary file not shown.
5 changes: 3 additions & 2 deletions app/assets/stylesheets/pages/_company.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.company-logo-img {
position: absolute;
bottom: -30px;
left: 20px;
left: 5%;
}

.company-link-btn {
Expand Down Expand Up @@ -41,7 +41,8 @@

.location {
color: gray;
font-size: 12px;
font-size: 13px;
font-weight: 300;
}

.seniority {
Expand Down
26 changes: 24 additions & 2 deletions app/controllers/companies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,37 @@ class CompaniesController < ApplicationController

skip_before_action :authenticate_user!
before_action :company_show_page_status, only: [:show]
before_action :set_company, only: %i[show]
before_action :set_jobs_and_departments, only: %i[show]

def show
@company = Company.find(params[:id])
@jobs = @company.jobs
@company_description = sanitize @company.description
end

private

def set_company
@company = Company.find(params[:id])
end

def filter_jobs
@jobs = JobFilteringService.new(@jobs, filter_params).filter_by_department
end

def set_jobs_and_departments
@jobs = @company.jobs
set_departments
filter_jobs
end

def set_departments
@departments = @jobs.pluck(:department).compact.uniq
end

def filter_params
params.permit(:department)
end

def company_show_page_status
redirect_to jobs_path, notice: "Company show page coming soon!" unless Flipper.enabled?(:company_show_page)
end
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/job_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def new
job.application_criteria.each do |field, details|
job_application.application_responses.build(
field_name: field,
field_label: details["label"],
field_locator: details["locators"],
interaction: details["interaction"],
field_option: details["option"],
field_options: details["options"].to_json,
required: details["required"],
field_value: current_user.try(field) || ""
field_value: current_user.try(field) || "",
core_field: details["core_field"]
)
end
job_application
Expand Down Expand Up @@ -99,7 +101,7 @@ def success
def job_application_params
params.require(:job_application).permit(
:job_id,
application_responses_attributes: [:field_name, { field_value: [] }, :field_value, :field_locator, :interaction, :field_option, :field_options, :cover_letter_content, :required]
application_responses_attributes: [:field_name, { field_value: [] }, :field_label, :field_value, :field_locator, :interaction, :field_option, :field_options, :required, :core_field]
)
end
end
9 changes: 7 additions & 2 deletions app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class JobsController < ApplicationController
before_action :job_show_page_status, only: [:show]

def index
@jobs = Job.filter_and_sort(params).paginate(page: params[:page], per_page: 20)
@resources = CategorySidebar.build_with(@jobs, params)
@jobs = jobs_and_associated_tables.filter_and_sort(params).paginate(page: params[:page], per_page: 20)
@resources = CategorySidebar.build_with(params)

@saved_jobs = SavedJob.all
@saved_job_ids = @saved_jobs.to_set(&:job_id)
Expand Down Expand Up @@ -36,4 +36,9 @@ def job_show_page_status
def job_params
params.require(:job).permit(:title, :description, :salary, :posting_url, :deadline, :date_posted, :company_id, :applicant_tracking_system_id, :ats_job_id, :non_geocoded_location_string, :department, :office, :live)
end

def jobs_and_associated_tables
associated_tables = params[:location] == 'remote' ? %i[requirement company] : %i[requirement company locations]
Job.includes(associated_tables)
end
end
6 changes: 6 additions & 0 deletions app/helpers/job_listings_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# app/helpers/job_listings_helper.rb
module JobListingsHelper
def partition_jobs(jobs)
jobs.partition { |job| job.department.present? }
end
end
19 changes: 19 additions & 0 deletions app/javascript/controllers/company_jobs_filter_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// company_jobs_filter_controller.js
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
connect() {
this.element.dataset.action = "change->company-jobs-filter#submit";
}

async submit() {
const value = this.element.value;
const url = this.element.dataset.url;
const turboType = this.element.dataset.turboType;
this.url = (`${url}?department=${value}`)

let frame = document.querySelector(`turbo-frame#${turboType}`)
frame.src = this.url
frame.reload();
}
}
10 changes: 5 additions & 5 deletions app/jobs/apply_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def perform(job_application_id, user_id)
application_criteria = assign_values_to_form(application, user)
fields_to_fill = application_criteria

form_filler = FormFiller.new
form_filler.fill_out_form(job.posting_url, fields_to_fill, job_application_id)
form_filler = FormFiller.new(job.posting_url, fields_to_fill, job_application_id)
form_filler.fill_out_form

user_channel_name = "job_applications_#{user.id}"

Expand All @@ -42,14 +42,14 @@ def assign_values_to_form(application, user)
end

application_criteria.each_key do |key|
if user.respond_to?(key) && user.send(key).present?
if custom_fields[key].nil? && user.respond_to?(key) && user.send(key).present?
application_criteria[key]['value'] = user.send(key)
else
application_criteria[key]['value'] = custom_fields[key]
# p "Warning: defaults does not have a method or attribute '#{key}'. Using NIL value instead"
# application_criteria[key]['value'] = nil
end
end
puts "Here are the application criteria:"
p application_criteria
return application_criteria
end
end
15 changes: 15 additions & 0 deletions app/jobs/build/all_companies_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Build
class AllCompaniesJob < ApplicationJob
queue_as :updates
retry_on StandardError, attempts: 0

def perform
CompanyBuilder.new.build
end

def perform_companies_and_jobs
CompanyBuilder.new.build
Build::AllJobsJob.perform_later
end
end
end
10 changes: 10 additions & 0 deletions app/jobs/build/all_jobs_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Build
class AllJobsJob < ApplicationJob
queue_as :updates
retry_on StandardError, attempts: 0

def perform
Build::AllJobs.new.build
end
end
end
24 changes: 13 additions & 11 deletions app/jobs/get_form_fields_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,20 @@ def perform(job)

# Stripping text, downcasing and replacing spaces with underscores to act as primary keys

label_text = label.xpath('descendant-or-self::text()[not(parent::select or parent::option or parent::ul or parent::label/input[@type="checkbox"])]').text.strip.downcase.gsub(
" ", "_"
)
label_text = label.xpath('descendant-or-self::text()[not(parent::select or parent::option or parent::ul or parent::label/input[@type="checkbox"])]').text

required = label_text.include?("*")
label_text = label_text.split("*")[0]

name = label_text
standard_fields = ['first_name', 'last_name', 'email', 'phone', 'resume/cv', 'cover_letter', 'city']
next if !name || name == "" || standard_fields.include?(remove_trailing_underscore(name))
name = label_text&.strip&.downcase&.gsub(" ", "_")
standard_fields = ['first_name', 'last_name', 'email', 'phone', 'resume/cv', 'cover_letter', 'city', 'location_(city)']
next if name.blank? || standard_fields.include?(remove_trailing_underscore(name))
next if label.parent.name == 'label'

attributes[name] = {
interaction: :input,
required:
required:,
label: label_text
}

inputs = label.css('input', 'textarea').reject { |input| input['type'] == 'hidden' || !input['id'] }
Expand All @@ -84,15 +83,18 @@ def perform(job)
demographics = nokogiri_form.css("#demographic_questions")
demographics_questions = demographics.css(".demographic_question")
demographics_questions.each do |question|
name = question.children.select(&:text?).map(&:text).join.strip.downcase.gsub(" ", "_")
label = question.children.select(&:text?).map(&:text).join.strip
name = label.downcase.gsub(" ", "_")
required = question['class'].include?('required')
attributes[name] = {
interaction: :checkbox
interaction: :checkbox,
required:,
label:
}
demographics_input = question.css('label:has(input[type="checkbox"])')
next if demographics_input.empty?

attributes[name][:locators] =
attributes[name][:locators] = question.children.select(&:text?).map(&:text).join.gsub("\n", ' ').strip
attributes[name][:locators] = question.children.select(&:text?).map(&:text).join.gsub("\n", ' ').strip
attributes[name][:options] = question.css('label:has(input[type="checkbox"])').map do |option|
option.text.strip
end
Expand Down
8 changes: 7 additions & 1 deletion app/jobs/update_existing_company_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class UpdateExistingCompanyJobs < ApplicationJob
# TODO: (1) for all the existing jobs on the site, we check whether those are still live (and delete if not)
# TODO: (2) for all the existing companies on the site, we check whether they have new jobs (and add if so)

# TODO: Update this so that it pulls the list of companies from the DB rather than the CSV

def perform
puts "Beginning jobs updater for companies already seeded to the DB..."

Expand Down Expand Up @@ -38,18 +40,22 @@ def fetch_jobs_and_companies

company_jobs = @ats.fetch_company_jobs(ats_identifier)

next unless company_jobs

# Create new jobs using AtsSystem method
company_jobs.each do |job_data|
@ats.find_or_create_job_by_data(company, job_data) if relevant?(job_data)
@job_urls.delete(@ats.fetch_url(job_data))
rescue StandardError => e
puts "Error: #{e}"
end
end
end
end

def relevant?(job_data)
# TODO: call the Relevant module method instead
title, job_location, remote = @ats_system.fetch_title_and_location(job_data)
title, job_location, remote = @ats.fetch_title_and_location(job_data)

(title &&
remote &&
Expand Down
Loading

0 comments on commit 172f4c1

Please sign in to comment.