Skip to content

Commit

Permalink
Merge branch 'master' into art/poa-requests/part-3/migrations.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ojbucao authored Dec 27, 2024
2 parents 9ead4aa + b9b7401 commit a53d6ae
Show file tree
Hide file tree
Showing 97 changed files with 2,325 additions and 519 deletions.
18 changes: 13 additions & 5 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ on:
permissions:
contents: read
jobs:
compare_sha:
runs-on: ubuntu-latest
name: Compare sha
steps:
- name: Compare commit ids
run: |
echo "github.sha: ${{ github.sha }}"
echo "github.event.push.head_commit.id: ${{ github.event.push.head_commit.id }}"
echo "github.event.pull_request.merge_commit_sha: ${{ github.event.pull_request.merge_commit_sha }}"
echo "github.event.head_commit.id: ${{ github.event.head_commit.id }}"
echo "github.event.workflow_run.head_commit.id: ${{ github.event.workflow_run.head_commit.id }}"
build_and_push:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Build and Push
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ permissions:
contents: read
checks: write
jobs:
compare_sha:
runs-on: ubuntu-latest
name: Compare sha
steps:
- name: Compare commit ids
run: |
echo "github.sha: ${{ github.sha }}"
echo "github.event.push.head_commit.id: ${{ github.event.push.head_commit.id }}"
echo "github.event.pull_request.merge_commit_sha: ${{ github.event.pull_request.merge_commit_sha }}"
echo "github.event.head_commit.id: ${{ github.event.head_commit.id }}"
linting_and_security:
name: Linting and Security
env:
Expand Down
19 changes: 9 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ GEM
bcp47 (0.3.3)
i18n
benchmark (0.4.0)
bigdecimal (3.1.8)
bigdecimal (3.1.8-java)
bigdecimal (3.1.9)
bindex (0.8.1)
blind_index (2.6.1)
activesupport (>= 7)
Expand Down Expand Up @@ -543,7 +542,7 @@ GEM
ffi (~> 1)
ffi-compiler (~> 1)
rake (>= 13)
googleauth (1.12.0)
googleauth (1.12.2)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.2)
google-logging-utils (~> 0.1)
Expand Down Expand Up @@ -611,8 +610,8 @@ GEM
jar-dependencies (0.5.1)
jmespath (1.6.2)
jruby-openssl (0.15.1-java)
json (2.9.0)
json (2.9.0-java)
json (2.9.1)
json (2.9.1-java)
json-schema (5.1.0)
addressable (~> 2.8)
json_schema (0.21.0)
Expand Down Expand Up @@ -653,7 +652,7 @@ GEM
ffi-compiler (~> 1.0)
rake (~> 13.0)
lockbox (2.0.0)
logger (1.6.3)
logger (1.6.4)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -884,8 +883,8 @@ GEM
request_store (1.7.0)
rack (>= 1.4)
require_all (3.0.0)
restforce (7.5.0)
faraday (>= 1.1.0, < 2.12.0)
restforce (8.0.0)
faraday (>= 1.1.0, < 3.0.0)
faraday-follow_redirects (<= 0.3.0, < 1.0.0)
faraday-multipart (>= 1.0.0, < 2.0.0)
faraday-net_http (< 4.0.0)
Expand Down Expand Up @@ -1051,7 +1050,7 @@ GEM
staccato (0.5.3)
statsd-instrument (3.9.7)
stringio (3.1.2)
strong_migrations (2.0.2)
strong_migrations (2.1.0)
activerecord (>= 6.1)
super_diff (0.14.0)
attr_extras (>= 6.2.4)
Expand All @@ -1065,7 +1064,7 @@ GEM
thread_safe (0.3.6-java)
tilt (2.3.0)
timecop (0.9.10)
timeout (0.4.2)
timeout (0.4.3)
trailblazer-option (0.1.2)
ttfunk (1.8.0)
bigdecimal (~> 3.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Vets API
This project provides common APIs for applications that live on VA.gov (formerly vets.gov APIs).
This project provides common APIs for applications that live on VA.gov (formerly vets.gov APIs).


[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/department-of-veterans-affairs/vets-api)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/claims_base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create

def show
submission = CentralMailSubmission.joins(:central_mail_claim).find_by(saved_claims: { guid: params[:id] })
render json: CentralMailSubmissionSerializer.new(submission)
render json: BenefitsIntakeSubmissionSerializer.new(submission)
end

private
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/v1/post911_gi_bill_statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Post911GIBillStatusesController < ApplicationController
include SentryLogging
service_tag 'gibill-statement'

STATSD_GI_BILL_TOTAL_KEY = 'api.lighthouse.gi_bill_status.total'
STATSD_GI_BILL_FAIL_KEY = 'api.lighthouse.gi_bill_status.fail'
STATSD_KEY_PREFIX = 'api.post911_gi_bill_status'

def show
response = service.get_gi_bill_status
Expand All @@ -20,15 +19,15 @@ def show
rescue => e
handle_error(e)
ensure
StatsD.increment(STATSD_GI_BILL_TOTAL_KEY)
StatsD.increment("#{STATSD_KEY_PREFIX}.total")
end

private

def handle_error(e)
status = e.errors.first[:status].to_i
log_vet_not_found(@current_user, Time.now.in_time_zone('Eastern Time (US & Canada)')) if status == 404
StatsD.increment(STATSD_GI_BILL_FAIL_KEY, tags: ["error:#{status}"])
StatsD.increment("#{STATSD_KEY_PREFIX}.fail", tags: ["error:#{status}"])
render json: { errors: e.errors }, status: status || :internal_server_error
end

Expand Down
21 changes: 21 additions & 0 deletions app/mailers/create_excel_files_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

class CreateExcelFilesMailer < ApplicationMailer
def build(filename)
date = Time.zone.now.strftime('%m/%d/%Y')
file_contents = File.read("tmp/#{filename}")
headers['Content-Disposition'] = "attachment; filename=#{filename}"

# rubocop:disable Layout/LineLength
recipients = Settings.vsp_environment.eql?('production') ? Settings.edu.production_excel_contents.emails : Settings.edu.staging_excel_contents.emails
subject = Settings.vsp_environment.eql?('production') ? "22-10282 Form CSV file for #{date}" : "Staging CSV file for #{date}"
# rubocop:enable Layout/LineLength

mail(
to: recipients,
subject: subject,
content_type: 'text/csv',
body: file_contents
)
end
end
2 changes: 1 addition & 1 deletion app/models/education_benefits_claim.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class EducationBenefitsClaim < ApplicationRecord
FORM_TYPES = %w[1990 1995 1990e 5490 5495 1990n 0993 0994 10203 1990s].freeze
FORM_TYPES = %w[1990 1995 1990e 5490 5495 1990n 0993 0994 10203 1990s 10282].freeze

APPLICATION_TYPES = %w[
chapter33
Expand Down
20 changes: 20 additions & 0 deletions app/models/excel_file_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class ExcelFileEvent < ApplicationRecord
validates :filename, uniqueness: true

# Look for an existing row with same filename
# and increase retry attempt if wasn't successful from previous attempt
# Otherwise create a new event
def self.build_event(filename)
filename_date = filename.match(/(.+)_/)[1]
event = find_by('filename like ?', "#{filename_date}%")

if event.present?
event.update(retry_attempt: event.retry_attempt + 1) if event.successful_at.nil?
return event
end

create(filename: filename)
end
end
11 changes: 11 additions & 0 deletions app/models/form_profiles/va_10282.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class FormProfiles::VA10282 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/applicant/information'
}
end
end
29 changes: 29 additions & 0 deletions app/models/saved_claim/education_benefits/va_10282.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

class SavedClaim::EducationBenefits::VA10282 < SavedClaim::EducationBenefits
add_form_and_validation('22-10282')

def after_submit(_user)
return unless Flipper.enabled?(:form22_10282_confirmation_email)

parsed_form_data = JSON.parse(form)
email = parsed_form_data['email']
return if email.blank?

send_confirmation_email(parsed_form_data, email)
end

private

def send_confirmation_email(parsed_form_data, email)
VANotify::EmailJob.perform_async(
email,
Settings.vanotify.services.va_gov.template_id.form22_10282_confirmation_email,
{
'first_name' => parsed_form_data.dig('veteranFullName', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => education_benefits_claim.confirmation_number
}
)
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class CentralMailSubmissionSerializer
class BenefitsIntakeSubmissionSerializer
include JSONAPI::Serializer

attribute :state
Expand Down
8 changes: 5 additions & 3 deletions app/services/bgs/dependent_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ def submit_to_central_service(claim:)
vet_info = JSON.parse(claim.form)['dependents_application']

user = BGS::SubmitForm686cJob.generate_user_struct(vet_info)
CentralMail::SubmitCentralForm686cJob.perform_async(claim.id,
KmsEncrypted::Box.new.encrypt(vet_info.to_json),
KmsEncrypted::Box.new.encrypt(user.to_h.to_json))
Lighthouse::BenefitsIntake::SubmitCentralForm686cJob.perform_async(
claim.id,
KmsEncrypted::Box.new.encrypt(vet_info.to_json),
KmsEncrypted::Box.new.encrypt(user.to_h.to_json)
)
end

def external_key
Expand Down
19 changes: 14 additions & 5 deletions app/sidekiq/bgs/submit_form674_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,22 @@ def self.generate_user_struct(encrypted_user_struct, vet_info)

def self.send_backup_submission(encrypted_user_struct_hash, vet_info, saved_claim_id, user_uuid)
user = generate_user_struct(encrypted_user_struct_hash, vet_info)
CentralMail::SubmitCentralForm686cJob.perform_async(saved_claim_id,
KmsEncrypted::Box.new.encrypt(vet_info.to_json),
KmsEncrypted::Box.new.encrypt(user.to_h.to_json))
Lighthouse::BenefitsIntake::SubmitCentralForm686cJob.perform_async(
saved_claim_id,
KmsEncrypted::Box.new.encrypt(vet_info.to_json),
KmsEncrypted::Box.new.encrypt(user.to_h.to_json)
)
InProgressForm.destroy_by(form_id: FORM_ID, user_uuid:)
rescue => e
Rails.logger.warn('BGS::SubmitForm674Job backup submission failed...',
{ user_uuid:, saved_claim_id:, error: e.message, nested_error: e.cause&.message })
Rails.logger.warn(
'BGS::SubmitForm674Job backup submission failed...',
{
user_uuid: user_uuid,
saved_claim_id: saved_claim_id,
error: e.message,
nested_error: e.cause&.message
}
)
InProgressForm.find_by(form_id: FORM_ID, user_uuid:)&.submission_pending!
end

Expand Down
8 changes: 5 additions & 3 deletions app/sidekiq/bgs/submit_form686c_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ def self.generate_user_struct(vet_info)

def self.send_backup_submission(vet_info, saved_claim_id, user_uuid)
user = generate_user_struct(vet_info)
CentralMail::SubmitCentralForm686cJob.perform_async(saved_claim_id,
KmsEncrypted::Box.new.encrypt(vet_info.to_json),
KmsEncrypted::Box.new.encrypt(user.to_h.to_json))
Lighthouse::BenefitsIntake::SubmitCentralForm686cJob.perform_async(
saved_claim_id,
KmsEncrypted::Box.new.encrypt(vet_info.to_json),
KmsEncrypted::Box.new.encrypt(user.to_h.to_json)
)
InProgressForm.destroy_by(form_id: FORM_ID, user_uuid:)
rescue => e
Rails.logger.warn('BGS::SubmitForm686cJob backup submission failed...',
Expand Down
Loading

0 comments on commit a53d6ae

Please sign in to comment.