Skip to content

Commit

Permalink
Feature/appeals 44915.uat 4.4.0 (#22694)
Browse files Browse the repository at this point in the history
* Add in appeals_tied_to_non_ssc_avljs methods and SQL

* Update case_docket.rb

* Update case_docket.rb

* APPEALS-51263 added the lever to the seeds file (#22149)

* Amybids/appeals 51263 (#22169)

* APPEALS-51263 added the lever to the seeds file

* APPEALS-51263 test cleanup for case_docket, case_distribution_levers_controller_spec and case_distribution_test_data_spec.rb

* APPEALS-51262 (#22176)

* creates trait in factory for non_ssc_avlj user

* updates user in user factory with new traits in staff factory

* adds randomized judge method

* replaces user create with a vacols staff create and limits css_id to 12 using slogid, adds judge_role for active smemgrp

* updates naming

---------

Co-authored-by: Michael Beard <michael.beard@va.gov>

* APPEALS-45232. Added table in the DB and added requested columns (#22223)

* APPEALS-45232. Added table in the DB and added requested columns

* APPEALS-45232. Fix lint issues

* APPEALS-45232. Fixed the class name

* APPEALS-45232. Updated the column names from feedback

---------

Co-authored-by: SHarshain <spoosa@razortalent.com>

* Sharsha/appeals 45200 (#22233)

* APPEALS-45200. create Return Appeals tied to non-SSC AVLJs job

* APPEALS-45200. WIP

---------

Co-authored-by: SHarshain <spoosa@razortalent.com>

* Chrisbdetlef/appeals 45208 (#22305)

* Framework for seeds

* Add comments and fill in further methods

* Further shared dev work

* Update names

* Expanded possible functions

* More functions for shared work

* Combine everyones work into main branch

* Combined work - testing

* Combined work - testing complete

* rubocop fix

---------

Co-authored-by: Christopher Detlef <>

* APPEALS-45202.Added button to trigger the job and return the appeals (#22375)

Co-authored-by: SHarshain <spoosa@razortalent.com>

* Updates slack_service.rb to include local/demo console printout message (#22343)

* APPEALS-51487 Location 63 Query (#22398)

* APPEALS-51487 Location 63 Query

* fix naming and change query

* Working code

* Add 2 day limit to query

* Remove commented out code

* Fix lint issues

* Remove binding.pry

---------

Co-authored-by: Christopher Detlef <>

* APPEALS-45248 ACD Controls Test Page Alerts for Run Seed Fils and Case Movement Section Buttons (#22386)

* APPEALS-45248 Add success banner alerts to Run seed files and case movement section buttons

* APPEALS-45248 add fail job button and refactored code

* Ricky/APPEALS-45204 (#22373)

* Added button, and initial csv generation of appeals tied to non ssc avljs

* WIP. APPEALS-45204 tweaks to Push data into CSV

* APPEALS-45204. fix the method error

* APPEALS-45204. Lint fix

* Updated query to fetch hearing and grab non ssc avlj names properly

* Fixed outstanding issues and cleaned up seeds

* implements new hearing_judge, separates assigned_avlj and signing_avlj

* Fixed linting issues and other clean up

---------

Co-authored-by: SHarshain <133917878+SHarshain@users.noreply.github.com>
Co-authored-by: SHarshain <spoosa@razortalent.com>
Co-authored-by: Michael Beard <michael.beard@va.gov>

* Ricky/APPEALS-45204 (#22452)

* Added button, and initial csv generation of appeals tied to non ssc avljs

* WIP. APPEALS-45204 tweaks to Push data into CSV

* APPEALS-45204. fix the method error

* APPEALS-45204. Lint fix

* Updated query to fetch hearing and grab non ssc avlj names properly

* Fixed outstanding issues and cleaned up seeds

* implements new hearing_judge, separates assigned_avlj and signing_avlj

* Fixed linting issues and other clean up

* Updated name of CSV download button

---------

Co-authored-by: SHarshain <133917878+SHarshain@users.noreply.github.com>
Co-authored-by: SHarshain <spoosa@razortalent.com>
Co-authored-by: Michael Beard <michael.beard@va.gov>

* Chrisbdetlef/appeals 54138 (#22460)

* APPEALS-51487 Location 63 Query

* fix naming and change query

* Working code

* Add 2 day limit to query

* Remove commented out code

* Fix lint issues

* Remove binding.pry

* APPEALS-54138 Add button to seed non-SSC AVLJs

---------

Co-authored-by: Christopher Detlef <>

* Fix for routing table (#22466)

Co-authored-by: Christopher Detlef <>

* Chrisbdetlef/appeals 54138.1 (#22486)

* Fix for routing table

* Randomly select docket id number

---------

Co-authored-by: Christopher Detlef <>

* Updated query to correctly grab seed data (#22489)

Co-authored-by: Amy Detwiler <133032208+amybids@users.noreply.github.com>

* Ricky/APPEALS-51260 (#22497)

* Updated query to correctly grab seed data

* Replaced AOD and CAVC fields with Priority, fixed csv file name

---------

Co-authored-by: Amy Detwiler <133032208+amybids@users.noreply.github.com>

* APPEALS-54884. spec fix push priority appeals to judges job (#22505)

Co-authored-by: SHarshain <spoosa@razortalent.com>

* exchanges spaces for hyphens, updates method to filter by unique veteran file numbers (#22524)

* updates seed file names to match AC and adds hyphens instead of spaces (#22530)

* Chrisbdetlef/appeals 54152 (#22531)

* APPEALS-54152 Move Appeals to loc 63

* Fix minor issues with the query and data displayed in the CSV

* APPEALS-54152 Move qualifying appeals to Loc 63

---------

Co-authored-by: Christopher Detlef <>

* APPEALS-54152.1 Fix issues with the process of making and moving appeals tied to nonSSC AVLJs (#22541)

Co-authored-by: Christopher Detlef <>

* Chrisbdetlef/appeals 54152.1 (#22544)

* APPEALS-54152.1 Fix issues with the process of making and moving appeals tied to nonSSC AVLJs

* TEST ONLY DO NOT MERGE

---------

Co-authored-by: Christopher Detlef <>

* Chrisbdetlef/appeals 54152.2 (#22554)

* APPEALS-54152.2 Change movement to loc 63 to 2 per AVLJ

* Fix lint issues and errors

* Remove artifact code

* Fix errors

---------

Co-authored-by: Christopher Detlef <>

* Code changes to account for duplicates from base query (#22582)

* Code changes to account for duplicates from base query

* Add warning to join constant

* Fix issue with empty array

---------

Co-authored-by: Christopher Detlef <>
Co-authored-by: Amy Detwiler <133032208+amybids@users.noreply.github.com>

* mbeard/APPEALS-45203 (#22565)

* refactored to include new move_qualifying_appeals method

* updated filtered methods and eligible appeals, moved appeals variables

* moves logic for eligible and moved appeals into new method

* cleaned up filter_method, simplified other methods

* updates to failing test

* ensures appeals isn't nil when job is complete

* Fix the last name issue on loc 63 CSV (#22591)

Co-authored-by: Christopher Detlef <>

* APPEALS-45248 v2 ACD Controls Test Page Alerts for Run Seed Fils and Case Movement Section Buttons (#22449)

* APPEALS-45248 Add success banner alerts to Run seed files and case movement section buttons

* APPEALS-45248 add fail job button and refactored code

* APPEALS-45248 address ac2 of the story and set timer for banner alerts

* APPEALS-45248-v2 update button verbiage

* APPEALS-54061 added collapsible table to see the 15 latest ReturnLegacyAppealsToBoard log on test page

* APPEALS-54061 refactor code to address modified AC in the story

* fixed linting issues

* some lint fixes

---------

Co-authored-by: 631966 <amy.detwiler@va.gov>
Co-authored-by: Amy Detwiler <133032208+amybids@users.noreply.github.com>

* APPEALS-APPEALS-55680 added nil checking to the return legacy to appe… (#22607)

* APPEALS-APPEALS-55680 added nil checking to the return legacy to appeals to board job

* APPEALS-55680 finish job if no moved appeals

* APPEALS-55680 made the no record slack message into an array

* APPEALS-55680 fixed rubocop issues

* mbeard/APPEALS-55179 (#22615)

* adds constants and updates method to use constant

* changes lever_group

* APPEALS-55179. Fix the query and update the Constant value

* updates method and puts constants to lowercase

* adds nonsscavlj_number_of_appeals_to_move to failing spec array

---------

Co-authored-by: SHarshain <spoosa@razortalent.com>

* mbeard/APPEALS-45203 (#22626)

* removes avljs from the slack message

* updates to slack messages

* APPEALS-54290 CSV for all tied VLJ cases (#22624)

Co-authored-by: Christopher Detlef <>

* APPEALS-56033 fixed duplicate, nil, and error handling (#22630)

* Amybids/appeals 56033 (#22635)

* APPEALS-56033 fixed duplicate, nil, and error handling

* APPEALS-56033 fix job running on frontend

* APPEALS-56033 fixed linting error

* Fix off by 1 error for returntoboard job (#22648)

* Fix off by 1 error for returntoboard job

* removed the extraneous space

* refactored the variables

* refactored variable names to fix rubocop issues

---------

Co-authored-by: Christopher Detlef <>
Co-authored-by: 631966 <amy.detwiler@va.gov>

* mbeard/APPEALS-55660 (#22653)

* Updates test coverage for full perform method

* fixed linting issues

* updates to receive and return a number of appeals moved

* updates value from 10 to 2 moved appeals

* adds trait to factory and lever to push priority spec

* APPEALS-56980 Fix for .perform_later functionality in higher environm… (#22671)

* APPEALS-56980 Fix for .perform_later functionality in higher environments

* Remove lines of code that aren't needed and add built in checker

* Fix 1 of 2 errors

* Move local variables out of intialize or callback methods

---------

Co-authored-by: Christopher Detlef <>

* APPEALS-55158 removed the skipped specs to make the test suite pass (#22651)

* Chrisbdetlef/appeals 54290 (#22647)

* APPEALS-54290 CSV for all tied VLJ cases

* Added support for AMA appeals

* Fix linting issues

---------

Co-authored-by: Christopher Detlef <>

* ricky/APPEALS-55123 (#22617)

* Added VLJ and Inactive Non-SSC AVLJ seeds

* Updated seeds to include signed and unsigned AMA appeals

* Fixed AMA hearing to not error on creation

---------

Co-authored-by: Amy Detwiler <133032208+amybids@users.noreply.github.com>

* Added docket back because sym doesn't provide the same information

* missed a merge conflict

* merge conflict resolved

* fixing the branch for UAT

---------

Co-authored-by: Matthew Roth <roth_matthew@bah.com>
Co-authored-by: Blake Manus <33578594+Blake-Manus@users.noreply.github.com>
Co-authored-by: Michael Beard <michael.beard@va.gov>
Co-authored-by: SHarshain <133917878+SHarshain@users.noreply.github.com>
Co-authored-by: SHarshain <spoosa@razortalent.com>
Co-authored-by: cdetlefva <133903625+cdetlefva@users.noreply.github.com>
Co-authored-by: Michael Beard <131783726+mbeardy@users.noreply.github.com>
Co-authored-by: kristeja <112115264+kristeja@users.noreply.github.com>
  • Loading branch information
9 people authored Sep 4, 2024
1 parent 40207d6 commit 037122a
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 239 deletions.
23 changes: 13 additions & 10 deletions app/jobs/return_legacy_appeals_to_board_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@
class ReturnLegacyAppealsToBoardJob < CaseflowJob
# For time_ago_in_words()
include ActionView::Helpers::DateHelper
# include RunAsyncable

queue_as :low_priority
queue_with_priority :low_priority
application_attr :queue

def initialize
@no_records_found_message = [Constants.DISTRIBUTION.no_records_moved_message].freeze
@nonsscavlj_number_of_appeals_limit = CaseDistributionLever.nonsscavlj_number_of_appeals_to_move || 0
@nonsscavlj_number_of_appeals_to_move = @nonsscavlj_number_of_appeals_limit - 1
end
NO_RECORDS_FOUND_MESSAGE = [Constants.DISTRIBUTION.no_records_moved_message].freeze

def perform
begin
returned_appeal_job = create_returned_appeal_job

appeals, moved_appeals = eligible_and_moved_appeals

return send_job_slack_report(@no_records_found_message) if moved_appeals.nil?
return send_job_slack_report(NO_RECORDS_FOUND_MESSAGE) if moved_appeals.nil?

complete_returned_appeal_job(returned_appeal_job, "Job completed successfully", moved_appeals)

Expand Down Expand Up @@ -115,10 +110,10 @@ def get_tied_appeal_bfkeys(tied_appeals)

def update_qualifying_appeals_bfkeys(tied_appeals_bfkeys, qualifying_appeals_bfkeys)
if tied_appeals_bfkeys.any?
if tied_appeals_bfkeys.count < @nonsscavlj_number_of_appeals_limit
if tied_appeals_bfkeys.count < nonsscavlj_number_of_appeals_limit
qualifying_appeals_bfkeys.push(tied_appeals_bfkeys)
else
qualifying_appeals_bfkeys.push(tied_appeals_bfkeys[0..@nonsscavlj_number_of_appeals_to_move])
qualifying_appeals_bfkeys.push(tied_appeals_bfkeys[0..max_appeals_limit_index])
end
end

Expand All @@ -129,6 +124,14 @@ def non_ssc_avljs
VACOLS::Staff.where("sactive = 'A' AND svlj = 'A' AND sattyid <> smemgrp")
end

def nonsscavlj_number_of_appeals_limit
@nonsscavlj_number_of_appeals_limit ||= (CaseDistributionLever.nonsscavlj_number_of_appeals_to_move || 0)
end

def max_appeals_limit_index
nonsscavlj_number_of_appeals_limit - 1
end

# Method to separate appeals by priority
def separate_by_priority(appeals)
return [] if appeals.nil?
Expand Down
5 changes: 5 additions & 0 deletions app/models/concerns/distribution_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,9 @@ def case_affinity_days_lever_value_is_selected?(lever_value)

true
end

def tied_to_judges(judge_ids)
with_appeal_affinities
.where(hearings: { judge_id: judge_ids })
end
end
6 changes: 6 additions & 0 deletions app/models/docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ def ready_priority_appeal_ids
appeals(priority: true, ready: true).pluck(:uuid)
end

def tied_to_vljs(judge_ids)
docket_appeals.ready_for_distribution
.most_recent_hearings
.tied_to_judges(judge_ids)
end

# rubocop:disable Metrics/MethodLength, Lint/UnusedMethodArgument, Metrics/PerceivedComplexity
# :reek:FeatureEnvy
def distribute_appeals(distribution, priority: false, genpop: nil, limit: 1, style: "push")
Expand Down
4 changes: 0 additions & 4 deletions app/models/hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ def daily_docket_conference_link
hearing_day.conference_link
end

def daily_docket_conference_link
hearing_day.conference_link
end

# returns scheduled datetime object considering the timezones
# @return [nil] if hearing_day is nil
# @return [Time] in scheduled_in_timezone timezone - if scheduled_datetime and scheduled_in_timezone are present
Expand Down
13 changes: 7 additions & 6 deletions app/queries/appeals_ready_for_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ def self.ready_appeals
.flat_map do |sym, docket|
appeals = docket.ready_to_distribute_appeals
if sym == :legacy
legacy_rows(appeals, sym)
legacy_rows(appeals, sym, docket)
else
ama_rows(appeals, docket, sym)
end
end
end

def self.legacy_rows(appeals, sym)
def self.legacy_rows(appeals, sym, docket)
appeals.map do |appeal|
build_appeal_row(appeal, sym)
build_appeal_row(appeal, sym, docket)
end
end

def self.build_appeal_row(appeal, sym)
def self.build_appeal_row(appeal, sym, docket)
veteran_name = format_veteran_name(appeal["snamef"], appeal["snamel"])
hearing_judge = format_vlj_name(appeal["vlj_namef"], appeal["vlj_namel"])
appeal_affinity = fetch_affinity_start_date(appeal["bfkey"])
Expand All @@ -69,8 +69,8 @@ def self.build_appeal_row(appeal, sym)
cavc: appeal["cavc"] == 1,
receipt_date: appeal["bfd19"],
ready_for_distribution_at: appeal["bfdloout"],
target_distro_date: target_distro_date(appeal["bfd19"], sym),
days_before_goal_date: days_before_goal_date(appeal["bfd19"], sym),
target_distro_date: target_distro_date(appeal["bfd19"], docket),
days_before_goal_date: days_before_goal_date(appeal["bfd19"], docket),
hearing_judge: hearing_judge,
original_judge: legacy_original_deciding_judge(appeal),
veteran_file_number: appeal["ssn"] || appeal["bfcorlid"],
Expand Down Expand Up @@ -99,6 +99,7 @@ def self.ama_rows(appeals, docket, sym)
ready_for_distribution_at = distribution_task_query(appeal)
# only look for hearings that were held
hearing_judge = with_held_hearings(appeal)

priority_appeal = appeal.aod || appeal.cavc
{
docket_number: appeal.docket_number,
Expand Down
68 changes: 60 additions & 8 deletions app/queries/appeals_tied_to_avljs_and_vljs_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ def self.tied_appeals

docket_coordinator.dockets
.flat_map do |sym, docket|
if sym == :legacy
appeals = docket.appeals_tied_to_avljs_and_vljs
unique_appeals = legacy_rows(appeals, sym).uniq { |record| record[:docket_number] }

unique_appeals
else
[]
end
if sym == :legacy
appeals = docket.appeals_tied_to_avljs_and_vljs
unique_appeals = legacy_rows(appeals, sym).uniq { |record| record[:docket_number] }

unique_appeals
else
appeals = docket.tied_to_vljs(vlj_user_ids)

ama_rows(appeals, sym)
end
end
end

def self.legacy_rows(appeals, sym)
Expand All @@ -70,6 +72,37 @@ def self.legacy_rows(appeals, sym)
end
end

def self.ama_rows(appeals, sym)
appeals.map do |appeal|
# # This comes from the DistributionTask's assigned_at date
# ready_for_distribution_at = distribution_task_query(appeal)
# only look for hearings that were held
hearing_judge = ama_hearing_judge(appeal)
signing_judge = ama_cavc_original_deciding_judge(appeal)
{
docket_number: appeal.docket_number,
docket: sym.to_s,
priority: appeal.aod || appeal.cavc,
receipt_date: appeal.receipt_date,
veteran_file_number: appeal.veteran_file_number,
veteran_name: appeal.veteran&.name.to_s,
vlj: hearing_judge,
hearing_judge: hearing_judge,
most_recent_signing_judge: signing_judge,
bfcurloc: nil
}
end
end

def self.vlj_user_ids
staff_domainids = VACOLS::Staff.where("svlj in ('A','J') AND sactive in ('A','I') ")
.pluck(:sdomainid)
.uniq
.compact

User.where(css_id: staff_domainids).pluck(:id)
end

def self.calculate_field_values(appeal)
vlj_name = get_vlj_name(appeal)
prev_judge_name = get_prev_judge_name(appeal)
Expand Down Expand Up @@ -110,4 +143,23 @@ def self.get_prev_judge_name(appeal)
def self.get_name_from_record(record)
FullName.new(record["snamef"], nil, record["snamel"]).to_s
end

def self.ama_hearing_judge(appeal)
appeal.hearings
.filter { |hearing| hearing.disposition = Constants.HEARING_DISPOSITION_TYPES.held }
.first&.judge&.full_name
end

def self.ama_cavc_original_deciding_judge(appeal)
return nil if appeal.cavc_remand.nil?

source_appeal_id = CavcRemand.find_by(remand_appeal: appeal).source_appeal_id
judge_css_id = Task.find_by(
appeal_id: source_appeal_id,
appeal_type: Appeal.name,
type: JudgeDecisionReviewTask.name
)&.assigned_to&.css_id

User.find_by_css_id(judge_css_id)&.full_name
end
end
Loading

0 comments on commit 037122a

Please sign in to comment.