From 7693361e9f852086f17b0957b13995d0cfab5a4a Mon Sep 17 00:00:00 2001 From: Matt Roth Date: Tue, 18 Apr 2023 16:28:16 -0400 Subject: [PATCH] ACD: Disable Legacy Docket and Non Priority distribution (#18463) * Update by_docket_date_distribution.rb * Update docket_coordinator.rb * disable Legacy * add feature toggle indicators to stats * Update by_docket_date_distribution.rb * Update push_priority_appeals_to_judges_job.rb --- .../push_priority_appeals_to_judges_job.rb | 8 ++++++- .../concerns/by_docket_date_distribution.rb | 22 ++++++++++++++----- app/models/distribution.rb | 2 ++ app/models/docket_coordinator.rb | 8 ++++++- db/schema.rb | 4 ++-- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/jobs/push_priority_appeals_to_judges_job.rb b/app/jobs/push_priority_appeals_to_judges_job.rb index 40b750a5084..bdb2ccc2363 100644 --- a/app/jobs/push_priority_appeals_to_judges_job.rb +++ b/app/jobs/push_priority_appeals_to_judges_job.rb @@ -57,7 +57,9 @@ def slack_report docket_coordinator.dockets.each_pair do |sym, docket| report << "*Number of #{sym} appeals _not_ distributed*: #{docket.count(priority: true, ready: true)}" end - report << "*Number of Legacy Hearing Non Genpop appeals _not_ distributed*: #{legacy_not_genpop_count}" + unless disable_legacy? + report << "*Number of Legacy Hearing Non Genpop appeals _not_ distributed*: #{legacy_not_genpop_count}" + end report << "" report << "*Debugging information*" @@ -179,6 +181,10 @@ def use_by_docket_date? FeatureToggle.enabled?(:acd_distribute_by_docket_date, user: RequestStore.store[:current_user]) end + def disable_legacy? + FeatureToggle.enabled?(:acd_disable_legacy_distributions, user: RequestStore.store[:current_user]) + end + def legacy_not_genpop_count docket_coordinator.dockets[:legacy].not_genpop_priority_count end diff --git a/app/models/concerns/by_docket_date_distribution.rb b/app/models/concerns/by_docket_date_distribution.rb index 1a816008b62..b55699e15ab 100644 --- a/app/models/concerns/by_docket_date_distribution.rb +++ b/app/models/concerns/by_docket_date_distribution.rb @@ -26,8 +26,10 @@ def requested_distribution priority_rem = priority_target.clamp(0, @rem) distribute_priority_appeals_from_all_dockets_by_age_to_limit(priority_rem, style: "request") - # Distribute the oldest nonpriority appeals from any docket if we haven't distributed {batch_size} appeals - distribute_nonpriority_appeals_from_all_dockets_by_age_to_limit(@rem) until @rem <= 0 + unless FeatureToggle.enabled?(:acd_disable_nonpriority_distributions, user: RequestStore.store[:current_user]) + # Distribute the oldest nonpriority appeals from any docket if we haven't distributed {batch_size} appeals + distribute_nonpriority_appeals_from_all_dockets_by_age_to_limit(@rem) until @rem <= 0 + end @appeals end @@ -57,17 +59,27 @@ def ama_statistics nonpriority_counts[sym] = docket.count(priority: false, ready: true) end - priority_counts[:legacy_hearing_tied_to] = legacy_hearing_priority_count(judge) - nonpriority_counts[:legacy_hearing_tied_to] = legacy_hearing_nonpriority_count(judge) + unless FeatureToggle.enabled?(:acd_disable_legacy_distributions, user: RequestStore.store[:current_user]) + priority_counts[:legacy_hearing_tied_to] = legacy_hearing_priority_count(judge) + nonpriority_counts[:legacy_hearing_tied_to] = legacy_hearing_nonpriority_count(judge) + end + nonpriority_counts[:iterations] = @nonpriority_iterations + settings = {} + feature_toggles = [:acd_disable_legacy_distributions, :acd_disable_nonpriority_distributions] + feature_toggles.each do |sym| + settings[sym] = FeatureToggle.enabled?(sym, user: RequestStore.store[:current_user]) + end + { batch_size: @appeals.count, total_batch_size: total_batch_size, priority_target: @push_priority_target || @request_priority_count, priority: priority_counts, nonpriority: nonpriority_counts, - algorithm: "by_docket_date" + algorithm: "by_docket_date", + settings: settings } end diff --git a/app/models/distribution.rb b/app/models/distribution.rb index 8ed1b84649a..fec5be90eca 100644 --- a/app/models/distribution.rb +++ b/app/models/distribution.rb @@ -92,6 +92,8 @@ def judge_tasks end def judge_legacy_tasks + return [] if FeatureToggle.enabled?(:acd_disable_legacy_distributions, user: RequestStore.store[:current_user]) + legacy_tasks = QueueRepository.tasks_for_user(judge.css_id) @judge_legacy_tasks ||= legacy_tasks.select { |task| task.assigned_to_attorney_date.nil? } diff --git a/app/models/docket_coordinator.rb b/app/models/docket_coordinator.rb index 2f78ff2d029..db72a7520fe 100644 --- a/app/models/docket_coordinator.rb +++ b/app/models/docket_coordinator.rb @@ -2,12 +2,18 @@ class DocketCoordinator def dockets - @dockets ||= { + all_dockets = { legacy: LegacyDocket.new, direct_review: DirectReviewDocket.new, evidence_submission: EvidenceSubmissionDocket.new, hearing: HearingRequestDocket.new } + + if FeatureToggle.enabled?(:acd_disable_legacy_distributions, user: RequestStore.store[:current_user]) + all_dockets.delete(:legacy) + end + + @dockets ||= all_dockets end def docket_proportions diff --git a/db/schema.rb b/db/schema.rb index b6faace638b..5e894ed7af8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -91,7 +91,7 @@ t.boolean "appeal_docketed", default: false, null: false, comment: "When true, appeal has been docketed" t.bigint "appeal_id", null: false, comment: "AMA or Legacy Appeal ID" t.string "appeal_type", null: false, comment: "Appeal Type (Appeal or LegacyAppeal)" - t.datetime "created_at", null: false, comment: "Date and Time the record was inserted into the table" + t.datetime "created_at", null: false t.bigint "created_by_id", null: false, comment: "User id of the user that inserted the record" t.boolean "decision_mailed", default: false, null: false, comment: "When true, appeal has decision mail request complete" t.boolean "hearing_postponed", default: false, null: false, comment: "When true, appeal has hearing postponed and no hearings scheduled" @@ -100,7 +100,7 @@ t.boolean "privacy_act_complete", default: false, null: false, comment: "When true, appeal has a privacy act request completed" t.boolean "privacy_act_pending", default: false, null: false, comment: "When true, appeal has a privacy act request still open" t.boolean "scheduled_in_error", default: false, null: false, comment: "When true, hearing was scheduled in error and none scheduled" - t.datetime "updated_at", comment: "Date and time the record was last updated" + t.datetime "updated_at" t.bigint "updated_by_id", comment: "User id of the last user that updated the record" t.boolean "vso_ihp_complete", default: false, null: false, comment: "When true, appeal has a VSO IHP request completed" t.boolean "vso_ihp_pending", default: false, null: false, comment: "When true, appeal has a VSO IHP request pending"