Skip to content

Commit

Permalink
Update Payload
Browse files Browse the repository at this point in the history
  • Loading branch information
patanj101 committed Jul 24, 2024
1 parent 1730c1f commit 71bea5e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/assets/builds/tailwind.css

Large diffs are not rendered by default.

15 changes: 1 addition & 14 deletions app/helpers/payload_application_processes_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Helper for building the payload page with reference JSON outputs
module PayloadApplicationProcessesHelper
def transformed_data(job_application)
job_application.api_payload
job_application.payload
end

def payload_title(job_app)
Expand All @@ -25,17 +25,4 @@ def company_name(job_app)
def job_title(job_app)
job_app.job.title
end

def payload_data(job_application)
questions = job_application.application_question_set.questions
questions.map do |question|
{
question.attribute => {
'selector' => question.selector,
'type' => question.type,
'value' => question.answered_value(job_application).to_s
}
}
end
end
end
5 changes: 4 additions & 1 deletion app/models/application_question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def answered_value(job_application)

def field = fields.first

def locator = field['selector'] || "##{field['id']}"

def multi_checkbox?
type.eql?("checkbox") && (options&.count&.> 1)
end
Expand All @@ -55,7 +57,8 @@ def options
end

def payload(job_application)
{ attribute: { input_text: type, value: answered_value(job_application) } }
# { attribute: { input_text: type, value: answered_value(job_application) } }
{ locator:, interaction: type, value: answered_value(job_application) }
end

def selector = field['selector'] || field['id']
Expand Down
7 changes: 5 additions & 2 deletions app/models/job_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ class JobApplication < ApplicationRecord
enum :status, { initial: "initial", completed: "completed", submitted: "submitted", rejected: "rejected" },
default: :initial, validate: true

def api_payload
application_question_set.questions.map do |question|
def payload
apply_url = job.posting_url
user_fullname = application_process.user.user_detail.full_name
fields = application_question_set.questions.map do |question|
question.payload(self)
end
{ user_fullname:, apply_url:, fields: }
end

def submitted?
Expand Down
2 changes: 1 addition & 1 deletion app/views/payload_application_processes/show.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= JSON.pretty_generate(payload_data(@job_application)) %>
<%= JSON.pretty_generate(@job_application.payload) %>

0 comments on commit 71bea5e

Please sign in to comment.