From 016a104b60ba9c3d2adf49ecbff5b2f41f5ef9e2 Mon Sep 17 00:00:00 2001 From: Amy Detwiler <133032208+amybids@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:53:15 -0400 Subject: [PATCH] Feature/appeals 44915.uat 4.4.0 (#22613) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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 * Sharsha/appeals 45200 (#22233) * APPEALS-45200. create Return Appeals tied to non-SSC AVLJs job * APPEALS-45200. WIP --------- Co-authored-by: SHarshain * 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 * 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 Co-authored-by: Michael Beard * 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 Co-authored-by: Michael Beard * 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 * 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 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 --------- Co-authored-by: Matthew Roth Co-authored-by: Blake Manus <33578594+Blake-Manus@users.noreply.github.com> Co-authored-by: Michael Beard Co-authored-by: SHarshain <133917878+SHarshain@users.noreply.github.com> Co-authored-by: SHarshain 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> Co-authored-by: HunJerBAH <99915461+HunJerBAH@users.noreply.github.com> --- .../return_legacy_appeals_to_board_job.rb | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/app/jobs/return_legacy_appeals_to_board_job.rb b/app/jobs/return_legacy_appeals_to_board_job.rb index f8662789ad2..29273939974 100644 --- a/app/jobs/return_legacy_appeals_to_board_job.rb +++ b/app/jobs/return_legacy_appeals_to_board_job.rb @@ -7,6 +7,7 @@ class ReturnLegacyAppealsToBoardJob < CaseflowJob queue_as :low_priority application_attr :queue + NO_RECORDS_MOVED_MESSAGE = ["Job Ran Successfully, No Records Moved"].freeze def perform(fail_job = false) begin @@ -15,22 +16,24 @@ def perform(fail_job = false) appeals, moved_appeals = eligible_and_moved_appeals + return send_job_slack_report(NO_RECORDS_MOVED_MESSAGE) if moved_appeals.nil? + complete_returned_appeal_job(returned_appeal_job, "Job completed successfully", moved_appeals) + # The rest of your code continues here # Filter the appeals and send the filtered report @filtered_appeals = filter_appeals(appeals, moved_appeals) - send_job_slack_report + send_job_slack_report(slack_report) rescue StandardError => error + @start_time ||= Time.zone.now message = "Job failed with error: #{error.message}" errored_returned_appeal_job(returned_appeal_job, message) - start_time ||= Time.zone.now # temporary fix to get this job to succeed - duration = time_ago_in_words(start_time) - slack_msg = "\n [ERROR] after running for #{duration}: #{error.message}" - slack_service.send_notification(slack_msg, self.class.name) + duration = time_ago_in_words(@start_time) + slack_service.send_notification("\n [ERROR] after running for #{duration}: #{error.message}", + self.class.name) log_error(error) message ensure - @start_time ||= Time.zone.now metrics_service_report_runtime(metric_group_name: "return_legacy_appeals_to_board_job") end end @@ -62,6 +65,8 @@ def eligible_and_moved_appeals end def grouped_by_avlj(moved_appeals) + return [] if moved_appeals.nil? + moved_appeals.group_by { |appeal| VACOLS::Staff.find_by(sattyid: appeal["vlj"])&.sattyid }.keys.compact end @@ -123,30 +128,37 @@ def non_ssc_avljs # Method to separate appeals by priority def separate_by_priority(appeals) - priority_appeals = appeals.select { |appeal| appeal["priority"] == 1 } - non_priority_appeals = appeals.select { |appeal| appeal["priority"] == 0 } + return [] if appeals.nil? + + priority_appeals = appeals.select { |appeal| appeal["priority"] == 1 } || [] + non_priority_appeals = appeals.select { |appeal| appeal["priority"] == 0 } || [] + [priority_appeals, non_priority_appeals] end # Method to calculate remaining eligible appeals def calculate_remaining_appeals(all_appeals, moved_priority_appeals, moved_non_priority_appeals) + return [] if all_appeals.nil? + remaining_priority_appeals = ( all_appeals.select { |appeal| appeal["priority"] == 1 } - moved_priority_appeals - ) + ) || [] remaining_non_priority_appeals = ( all_appeals.select { |appeal| appeal["priority"] == 0 } - moved_non_priority_appeals - ) + ) || [] [remaining_priority_appeals, remaining_non_priority_appeals] end # Method to fetch non-SSC AVLJs that appeals were moved to location '63' def fetch_moved_avljs(moved_appeals) + return [] if moved_appeals.nil? + moved_appeals.map { |appeal| VACOLS::Staff.find_by(sattyid: appeal["vlj"]) } .compact .uniq - .map { |record| get_name_from_record(record) } + &.map { |record| get_name_from_record(record) } || [] end def get_name_from_record(record) @@ -176,8 +188,8 @@ def errored_returned_appeal_job(returned_appeal_job, message) ) end - def send_job_slack_report - slack_service.send_notification(slack_report.join("\n"), self.class.name) + def send_job_slack_report(slack_message) + slack_service.send_notification(slack_message.join("\n"), self.class.name) end def slack_report