Skip to main content

Start Trial

To keep Org::Company's careers_access_status flow consistent we've added a TrialService (Org::Companies::TrialService) so we only interact with the TrialService instead of touching the careers_access_status attributes directly. Per June 2026 trial period is 2 weeks from first job posting. On first job posting, the TrialService.start_trial(...) will set careers_trial_ends_at to 2 weeks from the first job post and immediately schedule Org::Companies::EndTrialJob.perform_at(...) to perform at the careers_trials_ends_at

Code

# typed: true

module Org
module Companies
# Service class related to Org::Company TrialEndDate
class TrialService

extend T::Sig

sig {
params(
org_company: T.nilable(Org::Company),
careers_job: Careers::Job
).void
}
def self.start_trial(org_company:, careers_job:)
return if org_company.nil?

is_company_in_trial = org_company.careers_access_status == Org::Company.careers_access_statuses[:trial]
is_careers_trial_ends_at_empty = org_company.careers_trial_ends_at.nil?

return unless is_company_in_trial && is_careers_trial_ends_at_empty

first_careers_job_posting = careers_job.created_at
careers_trials_end_date = first_careers_job_posting + Org::Company::CAREERS_TRIAL_DURATION

org_company.update(
careers_trial_ends_at: careers_trials_end_date
)

end_trial_params = {
'org_company_id' => org_company.id
}

Org::Companies::EndTrialJob.perform_at(
careers_trials_end_date,
end_trial_params
)
end

sig {
}
def self.end_trial(org_company_id:)
end

end
end
end

Rule

Any action that should trigger the start of a careers trial should call TrialService.start_trial passing org_company_id which is the id of the Org::Company and careers_job because the careers_trial_ends_at value depends on the first careers_job post of the said company. per June 2026, this is implemented in:

  1. Careers::Jobs::EmployersCreateManager
     ActiveRecord::Base.transaction do
    job.save!
    ::Careers::Jobs::SyncService.execute(careers_job: job)
    ::Org::Companies::TrialService.start_trial(
    org_company: org_company,
    careers_job: job
    )
    end