Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/APPEALS-9461-V4
Browse files Browse the repository at this point in the history
  • Loading branch information
raymond-hughes authored Sep 13, 2023
2 parents 8a8ac60 + 35c1f4d commit 15dd619
Show file tree
Hide file tree
Showing 118 changed files with 1,793 additions and 2,589 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
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ def feedback_url
end
helper_method :feedback_url

def efolder_express_url
Rails.application.config.efolder_url.to_s
end
helper_method :efolder_express_url

def help_url
{
"certification" => certification_help_path,
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.

3 changes: 1 addition & 2 deletions app/controllers/help_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ class HelpController < ApplicationController

def feature_toggle_ui_hash(user = current_user)
{
programOfficeTeamManagement: FeatureToggle.enabled?(:program_office_team_management, user: user),
metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user)
programOfficeTeamManagement: FeatureToggle.enabled?(:program_office_team_management, user: user)
}
end

Expand Down
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
3 changes: 1 addition & 2 deletions app/controllers/intakes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def feature_toggle_ui_hash
eduPreDocketAppeals: FeatureToggle.enabled?(:edu_predocket_appeals, user: current_user),
updatedAppealForm: FeatureToggle.enabled?(:updated_appeal_form, user: current_user),
hlrScUnrecognizedClaimants: FeatureToggle.enabled?(:hlr_sc_unrecognized_claimants, user: current_user),
vhaClaimReviewEstablishment: FeatureToggle.enabled?(:vha_claim_review_establishment, user: current_user),
metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user)
vhaClaimReviewEstablishment: FeatureToggle.enabled?(:vha_claim_review_establishment, user: current_user)
}
end

Expand Down
24 changes: 0 additions & 24 deletions app/controllers/metrics/dashboard_controller.rb

This file was deleted.

44 changes: 0 additions & 44 deletions app/controllers/metrics/v2/logs_controller.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/controllers/stats_controller.rb

This file was deleted.

3 changes: 1 addition & 2 deletions app/controllers/test/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class Test::UsersController < ApplicationController
stats: "/stats",
jobs: "/jobs",
admin: "/admin",
test_veterans: "/test/data",
metrics_dashboard: "/metrics/dashboard"
test_veterans: "/test/data"
}
}
].freeze
Expand Down
Loading

0 comments on commit 15dd619

Please sign in to comment.