Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calvin/appeals 58200 #22865

Closed
wants to merge 82 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
dfe0102
Calvin/APPEALS-43852-cavc-levers (#21441)
calvincostaBAH Apr 30, 2024
9c76ad3
[APPEALS-43849]Update CAVC Affinity Implementation for AMA Dockets to…
samasudhirreddy Apr 30, 2024
e09beac
APPEALS-44956: Add AppealAffinity model and database table (#21526)
craigrva May 2, 2024
4141f56
Craig/appeals 44958 (#21564)
craigrva May 9, 2024
310ffcf
[Appeals 43850] Update Legacy Docket Queries to Account for the Previ…
seanrpa May 10, 2024
ff0f872
APPEALS-44959: Modify affinity date checks to use appeal_affinity (#2…
craigrva May 13, 2024
7a46496
Merge branch 'master' into feature/APPEALS-43179
craigrva May 16, 2024
07bba3d
APPEALS-44187: Factory Bot Additions (#21438)
isaiahsaucedo May 17, 2024
34641ca
Merge branch 'master' into feature/APPEALS-43179
craigrva May 17, 2024
0a4ccaf
Calvin/APPEALS-44957-rake-affinity (#21577)
calvincostaBAH May 17, 2024
e0afce1
Merge branch 'master' into feature/APPEALS-44916
craigrva May 17, 2024
6ce88de
APPEALS-46016: Add Affinity Start Date to the Explain Page (#21660)
craigrva May 17, 2024
8181165
Sudhir/appeals 43851 (#21613)
samasudhirreddy May 17, 2024
6579ea9
Craig/appeals 46196 (#21689)
craigrva May 21, 2024
baae791
APPEALS-43851: Add test to validate CAVC+AOD behavior on hearing dock…
craigrva May 22, 2024
13b195f
update rake task and spec (#21731)
craigrva May 24, 2024
3244e6d
APPEALS-46325: Add Seeds for AOD Appeals and Update Dates to Match CA…
craigrva May 24, 2024
e3a0993
APPEALS-45148: Hook to clear saved affinity date (#21623)
isaiahsaucedo May 30, 2024
e1fd851
Merge branch 'master' into feature/APPEALS-43179
craigrva May 31, 2024
4a10fa8
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva May 31, 2024
429d955
fix seeds/users_spec
craigrva May 31, 2024
8978540
add case dist lever to new tests (#21776)
craigrva May 31, 2024
7bf16f1
Merge branch 'feature/APPEALS-44916' of https://github.com/department…
craigrva May 31, 2024
7ffc3eb
fix tests, add lever to factory, fix dist scopes (#21779)
craigrva May 31, 2024
f1ae936
fix rubocop warning
craigrva May 31, 2024
d37db6e
Acd/appeals 43853 43854 (#21971)
calvincostaBAH Jun 28, 2024
65c552d
APPEALS-50692: Update Appeals Ready to Distribute CSV to include CAVC…
craigrva Jul 3, 2024
1233b7d
Calvin/appeals 44313 (#22119)
calvincostaBAH Jul 12, 2024
dbcb5ba
APPEALS-47741: Update the UpdateAppealAffinityDatesJob to add appeal_…
isaiahsaucedo Jul 18, 2024
d2bc0ed
fix rubocop warnings (#22225)
craigrva Jul 18, 2024
1060303
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Jul 18, 2024
6a69613
Fix rubocop and tests (#22231)
craigrva Jul 18, 2024
d03ebbd
APPEALS-52222: Add seed data file for AOJ remand return feature devel…
craigrva Jul 22, 2024
638a318
Calvin/appeals 52551 (#22293)
calvincostaBAH Jul 25, 2024
feb3aec
Craig/case docket optimization (#22294)
craigrva Jul 25, 2024
919e37d
Combination/appeals 50951 50966 50980 (#22250)
calvincostaBAH Jul 26, 2024
0c24656
Merge branch 'master' into feature/APPEALS-27523
craigrva Jul 26, 2024
e9304b3
Merge branch 'master' into feature/APPEALS-43179
craigrva Jul 29, 2024
29074e6
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Jul 29, 2024
f44f713
Update admin_ui_spec.rb for CAVC levers being enabled
craigrva Jul 29, 2024
d091cc7
Appeals-43900: Update Distribution Levers Seed Values to Enable in UI…
isaiahsaucedo Jul 29, 2024
eb573ad
APPEALS-50870: Add New Factory Trait to VACOLS/ Case for AOJ w/ Previ…
craigrva Jul 29, 2024
eeaaeed
Merge branch 'feature/APPEALS-43179' of https://github.com/department…
craigrva Jul 29, 2024
e972051
update admin_ui tests for AOJ levers being enabled
craigrva Jul 30, 2024
746a71c
Merge branch 'master' into feature/APPEALS-43179
craigrva Jul 31, 2024
7a352db
Merge branch 'master' into feature/APPEALS-27523
craigrva Aug 2, 2024
3f9d4e3
Merge branch 'master' into feature/APPEALS-43179
craigrva Aug 13, 2024
2466ee3
Combination/appeals 43899 43901 43902 (#22429)
samasudhirreddy Aug 15, 2024
7e2af42
APPEALS-53993: Update Implementation of Legacy Appeals with Hearing H…
craigrva Aug 16, 2024
37420a2
rspec addition for aoj (#22405)
isaiahsaucedo Aug 20, 2024
3541479
Update testing CSV files with affinity start date and original judge …
seanrpa Aug 20, 2024
39df9d6
Merge branch 'feature/APPEALS-43179' of https://github.com/department…
craigrva Aug 20, 2024
da772ff
Calvin/appeals 53712 (#22490)
calvincostaBAH Aug 20, 2024
e517496
Seed Data for Testing AOJ AOD Affinity Lever (#22501)
samasudhirreddy Aug 20, 2024
9ef986c
Merge branch 'master' into feature/APPEALS-27523
craigrva Aug 22, 2024
2b84666
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Aug 22, 2024
927b699
Merge branch 'feature/APPEALS-43179' of https://github.com/department…
craigrva Aug 22, 2024
56eb01f
Isaiah/appeals 43895 (#22536)
isaiahsaucedo Aug 23, 2024
cfd6a6c
Merge branch 'release/FY24Q4.4.0' into feature/APPEALS-43179
craigrva Sep 3, 2024
812cb9a
SeanP/APPEALS-55085: Add columns to distribution_stats for new AOJ le…
seanrpa Sep 3, 2024
d9034e4
add distribtuion stats to serializer in lower environments (#22559)
craigrva Sep 3, 2024
0022e0d
added test cases for infinite and omit levers with desired outcomes
craigrva Sep 3, 2024
6a66ef3
add check for hearing date to levers being infinite
craigrva Sep 3, 2024
940d0cc
fix lint
craigrva Sep 4, 2024
243fae2
Calvin/appeals 53978 (#22612)
calvincostaBAH Sep 5, 2024
bd15cc3
Update dist controller tests for addition of distribution_stats to th…
craigrva Sep 5, 2024
86d3132
Initial commit of Affinity_date_count (#22609)
samasudhirreddy Sep 9, 2024
0824596
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Sep 9, 2024
0d5ca02
Merge branch 'hotfix/APPEALS-57167' into Calvin/APPEALS-57225
calvincostaBAH Sep 9, 2024
5d1eeec
adding method to aoj case docket
calvincostaBAH Sep 9, 2024
829af18
APPEALS-55609: Cache case distribution lever values at beginning of P…
isaiahsaucedo Sep 10, 2024
4399b93
updated rspecs
calvincostaBAH Sep 10, 2024
37140cd
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Sep 10, 2024
336653e
Merge branch 'feature/APPEALS-27523' into Calvin/APPEALS-57225
calvincostaBAH Sep 10, 2024
ece451e
fix case factory defining correspondent twice
craigrva Sep 10, 2024
8397efe
Merge branch 'feature/APPEALS-27523' into Calvin/APPEALS-57225
calvincostaBAH Sep 10, 2024
94acceb
added cache clearing
calvincostaBAH Sep 10, 2024
49002f3
refactored spec tests
calvincostaBAH Sep 10, 2024
a6ced29
fixed rspec expectations
calvincostaBAH Sep 11, 2024
a4c9cca
fixed use of double update
calvincostaBAH Sep 11, 2024
94e4bd7
removed judge check for affinity filter
calvincostaBAH Sep 17, 2024
a19765d
Merge branch 'master' into Calvin/APPEALS-58200
calvincostaBAH Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/jobs/update_appeal_affinity_dates_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def process_legacy_appeals_which_need_affinity_updates(receipt_date_hashes_array

legacy_appeals_hash = VACOLS::CaseDocket.update_appeal_affinity_dates_query(receipt_date_hash[:priority],
receipt_date_hash[:receipt_date])
legacy_appeals_hash += VACOLS::AojCaseDocket.update_appeal_affinity_dates_query(receipt_date_hash[:priority],
receipt_date_hash[:receipt_date])
legacy_appeals_to_update_adjusted_for_affinity = legacy_appeals_with_no_appeal_affinities(legacy_appeals_hash)
create_or_update_appeal_affinities(legacy_appeals_to_update_adjusted_for_affinity, receipt_date_hash[:priority])
end
Expand Down
21 changes: 20 additions & 1 deletion app/models/case_distribution_lever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class CaseDistributionLever < ApplicationRecord
#{Constants.DISTRIBUTION.ama_hearing_docket_time_goals}
#{Constants.DISTRIBUTION.ama_hearing_start_distribution_prior_to_goals}
#{Constants.DISTRIBUTION.ama_evidence_submission_start_distribution_prior_to_goals}
#{Constants.DISTRIBUTION.aoj_affinity_days}
#{Constants.DISTRIBUTION.aoj_aod_affinity_days}
#{Constants.DISTRIBUTION.aoj_cavc_affinity_days}
).freeze

FLOAT_LEVERS = %W(
Expand Down Expand Up @@ -185,10 +188,20 @@ def snapshot
snapshot_hash
end

def clear_distribution_lever_cache
lever_items = CaseDistributionLever.all.map(&:item)

# Loop through each lever item and delete the corresponding cache
lever_items.each do |item|
cache_key = "#{item}_distribution_lever_cache"
Rails.cache.delete(cache_key)
end
end

private

def method_missing_value(name)
lever = find_by_item(name).try(:value)
lever = check_distribution_lever_cache(name)
begin
if INTEGER_LEVERS.include?(name)
Integer(lever)
Expand Down Expand Up @@ -246,5 +259,11 @@ def update_radio_options(lever, options)

lever["options"] = options
end

def check_distribution_lever_cache(name)
Rails.cache.fetch("#{name}_distribution_lever_cache", expires_in: 2.minutes) do
find_by_item(name).try(:value)
end
end
end
end
2 changes: 2 additions & 0 deletions app/models/concerns/by_docket_date_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def distribute_nonpriority_appeals_from_all_dockets_by_age_to_limit(limit, style
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def ama_statistics
docket_counts = {
aoj_legacy_priority_stats: {},
aoj_legacy_stats: {},
direct_review_priority_stats: {},
direct_review_stats: {},
evidence_submission_priority_stats: {},
Expand Down
2 changes: 2 additions & 0 deletions app/models/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def distribute!(limit = nil)
update!(status: "completed", completed_at: Time.zone.now, statistics: completed_statistics(ama_stats))

record_distribution_stats(ama_stats)

CaseDistributionLever.clear_distribution_lever_cache
end
rescue StandardError => error
process_error(error)
Expand Down
10 changes: 7 additions & 3 deletions app/models/docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def appeals(priority: nil, genpop: nil, ready: nil, judge: nil)
if ready
scope = scope.ready_for_distribution
scope = adjust_for_genpop(scope, genpop, judge) if judge.present? && !use_by_docket_date?
scope = adjust_for_affinity(scope, judge) if judge.present? && FeatureToggle.enabled?(:acd_exclude_from_affinity)
scope = adjust_for_affinity(scope, judge) if FeatureToggle.enabled?(:acd_exclude_from_affinity)
end

return scoped_for_priority(scope) if priority == true
Expand Down Expand Up @@ -203,8 +203,12 @@ def adjust_for_genpop(scope, genpop, judge)
(genpop == "not_genpop") ? scope.non_genpop_for_judge(judge) : scope.genpop
end

def adjust_for_affinity(scope, judge)
scope.genpop_with_case_distribution_lever.or(scope.non_genpop_with_case_distribution_lever(judge))
def adjust_for_affinity(scope, judge = nil)
if judge.present?
scope.genpop_with_case_distribution_lever.or(scope.non_genpop_with_case_distribution_lever(judge))
else
scope.genpop_with_case_distribution_lever
end
end

def scoped_for_priority(scope)
Expand Down
3 changes: 2 additions & 1 deletion app/models/docket_coordinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def dockets
legacy: LegacyDocket.new,
direct_review: DirectReviewDocket.new,
evidence_submission: EvidenceSubmissionDocket.new,
hearing: HearingRequestDocket.new
hearing: HearingRequestDocket.new,
aoj_legacy: AojLegacyDocket.new
}

@dockets ||= all_dockets
Expand Down
102 changes: 102 additions & 0 deletions app/models/dockets/aoj_legacy_docket.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# frozen_string_literal: true

class AojLegacyDocket < LegacyDocket
def ready_to_distribute_appeals
LegacyAppeal.aoj_appeal_repository.ready_to_distribute_appeals
end

# rubocop:disable Metrics/CyclomaticComplexity
def count(priority: nil, ready: nil)
counts_by_priority_and_readiness.inject(0) do |sum, row|
next sum unless (priority.nil? || (priority ? 1 : 0) == row["priority"]) &&
(ready.nil? || (ready ? 1 : 0) == row["ready"])

sum + row["n"]
end
end
# rubocop:enable Metrics/CyclomaticComplexity

def genpop_priority_count
LegacyAppeal.aoj_appeal_repository.genpop_priority_count
end

def not_genpop_priority_count
LegacyAppeal.aoj_appeal_repository.not_genpop_priority_count
end

def ready_priority_appeal_ids
LegacyAppeal.aoj_appeal_repository.priority_ready_appeal_vacols_ids
end

def oldest_priority_appeal_days_waiting
return 0 if age_of_oldest_priority_appeal.nil?

(Time.zone.now.to_date - age_of_oldest_priority_appeal.to_date).to_i
end

def age_of_oldest_priority_appeal
@age_of_oldest_priority_appeal ||=
if use_by_docket_date?
LegacyAppeal.aoj_appeal_repository.age_of_oldest_priority_appeal_by_docket_date
else
LegacyAppeal.aoj_appeal_repository.age_of_oldest_priority_appeal
end
end

def age_of_n_oldest_priority_appeals_available_to_judge(judge, num)
LegacyAppeal.aoj_appeal_repository.age_of_n_oldest_priority_appeals_available_to_judge(judge, num)
end

def age_of_n_oldest_nonpriority_appeals_available_to_judge(judge, num)
LegacyAppeal.aoj_appeal_repository.age_of_n_oldest_nonpriority_appeals_available_to_judge(judge, num)
end

def distribute_priority_appeals(distribution, style: "push", genpop: "any", limit: 1)
return [] unless should_distribute?(distribution, style: style, genpop: genpop)

LegacyAppeal.aoj_appeal_repository.distribute_priority_appeals(distribution.judge, genpop, limit).map do |record|
next unless existing_distribution_case_may_be_redistributed?(record["bfkey"], distribution)

dist_case = new_distributed_case(distribution, record, docket_type, genpop, true)
save_dist_case(dist_case)
dist_case
end.compact
end

# rubocop:disable Metrics/ParameterLists
def distribute_nonpriority_appeals(distribution,
style: "push",
genpop: "any",
range: nil,
limit: 1,
bust_backlog: false)
return [] unless should_distribute?(distribution, style: style, genpop: genpop)

return [] if !range.nil? && range <= 0

LegacyAppeal.aoj_appeal_repository.distribute_nonpriority_appeals(
distribution.judge, genpop, range, limit, bust_backlog
).map do |record|
next unless existing_distribution_case_may_be_redistributed?(record["bfkey"], distribution)

dist_case = new_distributed_case(distribution, record, docket_type, genpop, false)
save_dist_case(dist_case)
dist_case
end.compact
end
# rubocop:enable Metrics/ParameterLists

def priority_appeals_affinity_date_count(in_window)
LegacyAppeal.aoj_appeal_repository.priority_appeals_affinity_date_count(in_window).size
end

def non_priority_appeals_affinity_date_count(in_window)
LegacyAppeal.aoj_appeal_repository.non_priority_appeals_affinity_date_count(in_window).size
end

private

def counts_by_priority_and_readiness
@counts_by_priority_and_readiness ||= LegacyAppeal.aoj_appeal_repository.docket_counts_by_priority_and_readiness
end
end
20 changes: 17 additions & 3 deletions app/models/dockets/legacy_docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,24 @@ def distribute_nonpriority_appeals(distribution,
end
# rubocop:enable Metrics/ParameterLists

def priority_appeals_affinity_date_count(in_window)
LegacyAppeal.repository.priority_appeals_affinity_date_count(in_window).size
end

def non_priority_appeals_affinity_date_count(_in_window)
"N/A for legacy appeals which are nonpriority and non-AOJ"
end

# used for distribution_stats
# change parameters to in_window, priority once implemented
def affinity_date_count(*)
"not implemented"
# in_window refers to all cases with an appeal affinity still in their affinity window
# Out-of-window (in_window == false) refers to all other cases including cases that are
# out of their affinity window, tied_to, or genpop.
def affinity_date_count(in_window, priority)
if priority
priority_appeals_affinity_date_count(in_window)
else
non_priority_appeals_affinity_date_count(in_window)
end
end

private
Expand Down
4 changes: 4 additions & 0 deletions app/models/legacy_appeal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,10 @@ def repository
AppealRepository
end

def aoj_appeal_repository
AojAppealRepository
end

# Wraps the closure of appeals in a transaction
# add additional code inside the transaction by passing a block
def close(appeal: nil, appeals: nil, user:, closed_on:, disposition:)
Expand Down
Loading
Loading