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

APPEALS-36559 | Rubocop Fixes for by_docket_date_distribution.rb #20226

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
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
25 changes: 16 additions & 9 deletions app/models/concerns/by_docket_date_distribution.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true
almorbah marked this conversation as resolved.
Show resolved Hide resolved

# rubocop:disable Metrics/ModuleLength
module ByDocketDateDistribution
extend ActiveSupport::Concern
include CaseDistribution
Expand Down Expand Up @@ -50,6 +49,7 @@ def distribute_nonpriority_appeals_from_all_dockets_by_age_to_limit(limit, style
end
end

# rubocop:disable Metrics/MethodLength
def ama_statistics
priority_counts = { count: priority_count }
nonpriority_counts = { count: nonpriority_count }
Expand Down Expand Up @@ -82,14 +82,18 @@ def ama_statistics
settings: settings
}
end
# rubocop:enable Metrics/MethodLength

def num_oldest_priority_appeals_for_judge_by_docket(distribution, num)
return {} unless num > 0

dockets
.flat_map { |sym, docket| docket.age_of_n_oldest_priority_appeals_available_to_judge(
distribution.judge, num).map { |age| [age, sym] } }
.sort_by { |age, _| age }
mapped_dockets = dockets.flat_map do |sym, docket|
docket.age_of_n_oldest_priority_appeals_available_to_judge(
distribution.judge, num
).map { |age| [age, sym] }
end

mapped_dockets.sort_by { |age, _| age }
.first(num)
.group_by { |_, sym| sym }
.transform_values(&:count)
Expand All @@ -98,10 +102,13 @@ def num_oldest_priority_appeals_for_judge_by_docket(distribution, num)
def num_oldest_nonpriority_appeals_for_judge_by_docket(distribution, num)
return {} unless num > 0

dockets
.flat_map { |sym, docket| docket.age_of_n_oldest_nonpriority_appeals_available_to_judge(
distribution.judge, num).map { |age| [age, sym] } }
.sort_by { |age, _| age }
mapped_dockets = dockets.flat_map do |sym, docket|
docket.age_of_n_oldest_nonpriority_appeals_available_to_judge(
distribution.judge, num
).map { |age| [age, sym] }
end

mapped_dockets.sort_by { |age, _| age }
.first(num)
.group_by { |_, sym| sym }
.transform_values(&:count)
Expand Down
Loading