Skip to content

Commit

Permalink
Merge branch 'master' into aedara/APPEALS-29105
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandEdara authored Sep 14, 2023
2 parents 93a598a + 433f7ca commit a1bec0d
Show file tree
Hide file tree
Showing 75 changed files with 1,316 additions and 1,389 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ plugins:
languages:
ruby:
javascript:
mass_threshold: 50
mass_threshold: 81
exclude_patterns:
- 'db/migrate/*'
- 'app/controllers/idt/api/v2/appeals_controller.rb'
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,16 @@ jobs:
- name: Install Node Dependencies
run: ./ci-bin/capture-log "cd client && yarn install --frozen-lockfile"

- name: Danger
run: ./ci-bin/capture-log "bundle exec danger"
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
# - name: Danger
# run: ./ci-bin/capture-log "bundle exec danger"
# env:
# DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}

- name: Lint
run: ./ci-bin/capture-log "bundle exec rake lint"
if: ${{ always() }}

- name: Security
run: ./ci-bin/capture-log "bundle exec rake security"
if: ${{ always() }}
# - name: Security
# run: ./ci-bin/capture-log "bundle exec rake security"
# if: ${{ always() }}

1 change: 1 addition & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ detectors:
- Reporter#percent
- SanitizedJsonConfiguration
- ScheduleHearingTaskPager#sorted_tasks
- UpdatePOAConcern
- VBMSCaseflowLogger#log
- LegacyDocket
UnusedParameters:
Expand Down
55 changes: 2 additions & 53 deletions app/controllers/appeals_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class AppealsController < ApplicationController
include UpdatePOAConcern
before_action :react_routed
before_action :set_application, only: [:document_count, :power_of_attorney, :update_power_of_attorney]
# Only whitelist endpoints VSOs should have access to.
Expand Down Expand Up @@ -97,21 +98,7 @@ def power_of_attorney
end

def update_power_of_attorney
clear_poa_not_found_cache
if cooldown_period_remaining > 0
render json: {
alert_type: "info",
message: "Information is current at this time. Please try again in #{cooldown_period_remaining} minutes",
power_of_attorney: power_of_attorney_data
}
else
message, result, status = update_or_delete_power_of_attorney!
render json: {
alert_type: result,
message: message,
power_of_attorney: (status == "updated") ? power_of_attorney_data : {}
}
end
update_poa_information(appeal)
rescue StandardError => error
render_error(error)
end
Expand Down Expand Up @@ -294,21 +281,6 @@ def docket_number?(search)
!search.nil? && search.match?(/\d{6}-{1}\d+$/)
end

def update_or_delete_power_of_attorney!
appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) # clear memoization on legacy appeals
poa = appeal.bgs_power_of_attorney

if poa.blank?
["Successfully refreshed. No power of attorney information was found at this time.", "success", "blank"]
elsif poa.bgs_record == :not_found
poa.destroy!
["Successfully refreshed. No power of attorney information was found at this time.", "success", "deleted"]
else
poa.save_with_updated_bgs_record!
["POA Updated Successfully", "success", "updated"]
end
end

def send_initial_notification_letter
# depending on the docket type, create cooresponding task as parent task
case appeal.docket_type
Expand Down Expand Up @@ -339,29 +311,6 @@ def power_of_attorney_data
}
end

def clear_poa_not_found_cache
Rails.cache.delete("bgs-participant-poa-not-found-#{appeal&.veteran&.file_number}")
Rails.cache.delete("bgs-participant-poa-not-found-#{appeal&.claimant_participant_id}")
end

def cooldown_period_remaining
next_update_allowed_at = appeal.poa_last_synced_at + 10.minutes if appeal.poa_last_synced_at.present?
if next_update_allowed_at && next_update_allowed_at > Time.zone.now
return ((next_update_allowed_at - Time.zone.now) / 60).ceil
end

0
end

def render_error(error)
Rails.logger.error("#{error.message}\n#{error.backtrace.join("\n")}")
Raven.capture_exception(error, extra: { appeal_type: appeal.type, appeal_id: appeal.id })
render json: {
alert_type: "error",
message: "Something went wrong"
}, status: :unprocessable_entity
end

# Purpose: Fetches all notifications for an appeal
#
# Params: appeals_id (vacols_id OR uuid)
Expand Down
64 changes: 64 additions & 0 deletions app/controllers/concerns/update_poa_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# frozen_string_literal: true

module UpdatePOAConcern
extend ActiveSupport::Concern
# these two methods were previously in appeals controller trying to see if they can be brought here.

def clear_poa_not_found_cache(appeal)
Rails.cache.delete("bgs-participant-poa-not-found-#{appeal&.veteran&.file_number}")
Rails.cache.delete("bgs-participant-poa-not-found-#{appeal&.claimant_participant_id}")
end

def cooldown_period_remaining(appeal)
next_update_allowed_at = appeal.poa_last_synced_at + 10.minutes if appeal.poa_last_synced_at.present?
if next_update_allowed_at && next_update_allowed_at > Time.zone.now
return ((next_update_allowed_at - Time.zone.now) / 60).ceil
end

0
end

def update_or_delete_power_of_attorney!(appeal)
appeal.power_of_attorney&.try(:clear_bgs_power_of_attorney!) # clear memoization on legacy appeals
poa = appeal.bgs_power_of_attorney
if poa.blank?
[COPY::POA_SUCCESSFULLY_REFRESH_MESSAGE, "success", "blank"]
elsif poa.bgs_record == :not_found
poa.destroy!
[COPY::POA_SUCCESSFULLY_REFRESH_MESSAGE, "success", "deleted"]
else
poa.save_with_updated_bgs_record!
[COPY::POA_UPDATED_SUCCESSFULLY, "success", "updated"]
end
rescue StandardError => error
[error, "error", "updated"]
end

def update_poa_information(appeal)
clear_poa_not_found_cache(appeal)
cooldown_period = cooldown_period_remaining(appeal)
if cooldown_period > 0
render json: {
alert_type: "info",
message: "Information is current at this time. Please try again in #{cooldown_period} minutes",
power_of_attorney: power_of_attorney_data
}
else
message, result, status = update_or_delete_power_of_attorney!(appeal)
render json: {
alert_type: result,
message: message,
power_of_attorney: (status == "updated") ? power_of_attorney_data : {}
}
end
end

def render_error(error)
Rails.logger.error("#{error.message}\n#{error.backtrace.join("\n")}")
Raven.capture_exception(error, extra: { appeal_type: appeal.type, appeal_id: appeal.id })
render json: {
alert_type: "error",
message: "Something went wrong"
}, status: :unprocessable_entity
end
end
23 changes: 23 additions & 0 deletions app/controllers/decision_reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class DecisionReviewsController < ApplicationController
include GenericTaskPaginationConcern
include UpdatePOAConcern

before_action :verify_access, :react_routed, :set_application
before_action :verify_veteran_record_access, only: [:show]
Expand Down Expand Up @@ -89,6 +90,17 @@ def task_filter_details
}
end

def power_of_attorney
render json: power_of_attorney_data
end

def update_power_of_attorney
appeal = task.appeal
update_poa_information(appeal)
rescue StandardError => error
render_error(error)
end

helper_method :task_filter_details, :business_line, :task

private
Expand Down Expand Up @@ -174,4 +186,15 @@ def allowed_params
decision_issues: [:description, :disposition, :request_issue_id]
)
end

def power_of_attorney_data
{
representative_type: task.appeal&.representative_type,
representative_name: task.appeal&.representative_name,
representative_address: task.appeal&.representative_address,
representative_email_address: task.appeal&.representative_email_address,
representative_tz: task.appeal&.representative_tz,
poa_last_synced_at: task.appeal&.poa_last_synced_at
}
end
end
36 changes: 0 additions & 36 deletions app/controllers/dispatch_stats_controller.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/controllers/idt/api/v2/distributions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def pending_establishment(distribution_id)

def format_response(response)
response_body = response.raw_body

begin
parsed_response = if [ActiveSupport::HashWithIndifferentAccess, Hash].include?(response_body.class)
response_body
Expand Down
10 changes: 0 additions & 10 deletions app/controllers/stats_controller.rb

This file was deleted.

12 changes: 0 additions & 12 deletions app/jobs/calculate_dispatch_stats_job.rb

This file was deleted.

15 changes: 0 additions & 15 deletions app/models/appeal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

# rubocop:disable Metrics/ClassLength
class Appeal < DecisionReview
include AppealConcern
include BeaamAppealConcern
include BgsService
include Taskable
Expand Down Expand Up @@ -62,16 +61,6 @@ class Appeal < DecisionReview
:email_address,
:country, to: :veteran, prefix: true

delegate :power_of_attorney, to: :claimant
delegate :representative_name,
:representative_type,
:representative_address,
:representative_email_address,
:poa_last_synced_at,
:update_cached_attributes!,
:save_with_updated_bgs_record!,
to: :power_of_attorney, allow_nil: true

enum stream_type: {
Constants.AMA_STREAM_TYPES.original.to_sym => Constants.AMA_STREAM_TYPES.original,
Constants.AMA_STREAM_TYPES.vacate.to_sym => Constants.AMA_STREAM_TYPES.vacate,
Expand Down Expand Up @@ -769,10 +758,6 @@ def untimely_issues_report(new_date)
issues_report
end

def bgs_power_of_attorney
claimant&.is_a?(BgsRelatedClaimant) ? power_of_attorney : nil
end

# Note: Currently Caseflow only supports one claimant per decision review
def power_of_attorneys
claimants.map(&:power_of_attorney).compact
Expand Down
30 changes: 0 additions & 30 deletions app/models/certification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ def form8
@form8 ||= Form8.find_by(certification_id: id)
end

def time_to_certify
return nil if !completed_at || !created_at

completed_at - created_at
end

def self.completed
where("completed_at IS NOT NULL")
end
Expand All @@ -127,30 +121,6 @@ def self.v2
.or(where.not(vacols_representative_name: nil))
end

def self.was_missing_doc
was_missing_nod.or(was_missing_soc)
.or(was_missing_ssoc)
.or(was_missing_form9)
end

def self.was_missing_nod
# allow 30 second lag just in case 'nod_matching_at' timestamp is a few seconds
# greater than 'created_at' timestamp
where(nod_matching_at: nil).or(where("nod_matching_at > created_at + INTERVAL '30 seconds'"))
end

def self.was_missing_soc
where(soc_matching_at: nil).or(where("soc_matching_at > created_at + INTERVAL '30 seconds'"))
end

def self.was_missing_ssoc
ssoc_required.where(ssocs_matching_at: nil).or(where("ssocs_matching_at > created_at + INTERVAL '30 seconds'"))
end

def self.was_missing_form9
where(form9_matching_at: nil).or(where("form9_matching_at > created_at + INTERVAL '30 seconds'"))
end

def self.ssoc_required
where(ssocs_required: true)
end
Expand Down
Loading

0 comments on commit a1bec0d

Please sign in to comment.