Class: FormSubmissionAttempt
Constant Summary
collapse
- HOUR_TO_SEND_NOTIFICATIONS =
9
Class Method Summary
collapse
Instance Method Summary
collapse
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Class Method Details
.latest_attempts ⇒ Object
23
24
25
26
|
# File 'app/models/form_submission_attempt.rb', line 23
def self.latest_attempts
select('DISTINCT ON (form_submission_id) form_submission_id, benefits_intake_uuid')
.order('form_submission_id, created_at DESC')
end
|
Instance Method Details
#log_status_change ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'app/models/form_submission_attempt.rb', line 74
def log_status_change
log_hash = {
form_submission_id:,
benefits_intake_uuid:,
form_type: form_submission&.form_type,
from_state: aasm.from_state,
to_state: aasm.to_state,
event: aasm.current_event
}
case aasm.current_event
when 'fail!'
log_hash[:message] = 'Form Submission Attempt failed'
Rails.logger.error(log_hash)
when 'vbms!'
log_hash[:message] = 'Form Submission Attempt went to vbms'
when 'manual!'
log_hash[:message] = 'Form Submission Attempt is being manually remediated'
else
log_hash[:message] = 'Form Submission Attempt State change'
end
Rails.logger.info(log_hash) if aasm.current_event != 'fail!'
end
|
106
107
108
109
110
111
112
113
114
|
# File 'app/models/form_submission_attempt.rb', line 106
def queue_form526_form4142_email(form526_submission_id, log_info)
Rails.logger.info('Queuing Form526:Form4142 failure email to VaNotify',
log_info.merge({ form526_submission_id: }))
jid = EVSS::DisabilityCompensationForm::Form4142DocumentUploadFailureEmail.perform_async(
form526_submission_id
)
Rails.logger.info('Queuing Form526:Form4142 failure email to VaNotify completed',
log_info.merge({ jid:, form526_submission_id: }))
end
|
136
137
138
|
# File 'app/models/form_submission_attempt.rb', line 136
def should_send_simple_forms_email
simple_forms_form_number && Flipper.enabled?(:simple_forms_email_notifications)
end
|
101
102
103
104
|
# File 'app/models/form_submission_attempt.rb', line 101
def simple_forms_api_email(log_info)
Rails.logger.info('Preparing to send Form Submission Attempt error email', log_info)
simple_forms_enqueue_result_email(:error)
end
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'app/models/form_submission_attempt.rb', line 140
def simple_forms_enqueue_result_email(notification_type)
raw_form_data = form_submission.form_data || '{}'
form_data = JSON.parse(raw_form_data)
config = {
form_data:,
form_number: simple_forms_form_number,
confirmation_number: benefits_intake_uuid,
date_submitted: created_at.strftime('%B %d, %Y'),
lighthouse_updated_at: lighthouse_updated_at&.strftime('%B %d, %Y')
}
SimpleFormsApi::NotificationEmail.new(
config,
notification_type:,
user_account:
).send(at: time_to_send)
end
|
170
171
172
173
174
175
176
177
|
# File 'app/models/form_submission_attempt.rb', line 170
def simple_forms_form_number
@simple_forms_form_number ||=
if SimpleFormsApi::NotificationEmail::TEMPLATE_IDS.keys.include? form_submission.form_type
form_submission.form_type
else
SimpleFormsApi::V1::UploadsController::FORM_NUMBER_MAP[form_submission.form_type]
end
end
|