Skip to content

Commit

Permalink
Adding zip backup (#12445)
Browse files Browse the repository at this point in the history
* Adding zip backup

* rubo

* making method 1 less line to appease rubocop
  • Loading branch information
kylesoskin authored Apr 20, 2023
1 parent 4b68508 commit 313a508
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions app/controllers/v1/supplemental_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def create
req_body_obj = request_body_hash.is_a?(String) ? JSON.parse(request_body_hash) : request_body_hash
form4142 = req_body_obj.delete('form4142')
sc_evidence = req_body_obj.delete('additionalDocuments')
zip_from_frontend = req_body_obj.dig('data', 'attributes', 'veteran', 'address', 'zipCode5')
sc_response = decision_review_service.create_supplemental_claim(request_body: req_body_obj, user: @current_user)
submitted_appeal_uuid = sc_response.body.dig('data', 'id')
unless submitted_appeal_uuid.nil?
appeal_submission, _ipf_id = clear_in_progress_form(submitted_appeal_uuid)
appeal_submission, _ipf_id = clear_in_progress_form(submitted_appeal_uuid, zip_from_frontend)
appeal_submission_id = appeal_submission.id
::Rails.logger.info(post_create_log_msg(appeal_submission_id:, submitted_appeal_uuid:))
if form4142.present?
handle_4142(request_body: req_body_obj,
form4142:, response: sc_response,
appeal_submission_id:,
submitted_appeal_uuid:)
appeal_submission_id:, submitted_appeal_uuid:)
end
submit_evidence(sc_evidence, appeal_submission_id, submitted_appeal_uuid) if sc_evidence.present?
render json: sc_response.body, status: sc_response.status
Expand Down Expand Up @@ -97,14 +97,16 @@ def handle_personal_info_error(e)
raise
end

def clear_in_progress_form(submitted_appeal_uuid)
def clear_in_progress_form(submitted_appeal_uuid, backup_zip)
ret = [nil, nil]
ActiveRecord::Base.transaction do
ret[0] = AppealSubmission.create! user_uuid: @current_user.uuid,
user_account: @current_user.user_account,
type_of_appeal: 'SC',
submitted_appeal_uuid:,
upload_metadata: DecisionReviewV1::Service.file_upload_metadata(@current_user)
upload_metadata: DecisionReviewV1::Service.file_upload_metadata(
@current_user, backup_zip
)
# Clear in-progress form since submit was successful
ret[1] = InProgressForm.form_for_user('20-0995', @current_user)&.destroy!
end
Expand Down
4 changes: 2 additions & 2 deletions lib/decision_review_v1/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ def get_notice_of_disagreement_upload(guid:)
end
end

def self.file_upload_metadata(user)
def self.file_upload_metadata(user, backup_zip = nil)
{
'veteranFirstName' => transliterate_name(user.first_name),
'veteranLastName' => transliterate_name(user.last_name),
'zipCode' => user.postal_code,
'zipCode' => user.postal_code || backup_zip,
'fileNumber' => user.ssn.to_s.strip,
'source' => 'va.gov',
'businessLine' => 'BVA',
Expand Down

0 comments on commit 313a508

Please sign in to comment.