-
Notifications
You must be signed in to change notification settings - Fork 19
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
[Part 4] Create non default distribution seed data #14802
Merged
hschallhorn
merged 31 commits into
hschallhorn/14604-job-report
from
hschallhorn/14604-testing
Sep 4, 2020
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
3bf5af0
Better handling of dispatch judge and atty
hschallhorn 81fa04b
Fix factories to be able to be called after resetting sequences
hschallhorn edb3bcd
Add distribution seed file
hschallhorn 0b7a931
Add a case that will error
hschallhorn 0933296
Integrate bug fix
hschallhorn 4ad20a7
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 7986f95
Fix job
hschallhorn 8070de9
Fixes
hschallhorn 505ca1b
Fix report
hschallhorn a1d7e54
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn f441a66
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn cab8086
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn c0ab88b
Fix tied to judge trait
hschallhorn f883fef
User random keys
hschallhorn 692eff2
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 2d796ff
Integrate changes from fix
hschallhorn 4554d88
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 1f581e0
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 0f5188a
Fix tests
hschallhorn 8d3e300
Merge branch 'master' into hschallhorn/14604-testing
hschallhorn e10e5f8
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn a1c8ab6
Code climate
hschallhorn 7bf0dd4
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn a89d1bf
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 05e9a42
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 92e163d
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn af12a4d
Feedback
hschallhorn 42fecd0
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 3acdd66
Update priority_distributions.rb
hschallhorn 0f03b97
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn 0dfb2f1
Merge branch 'hschallhorn/14604-job-report' into hschallhorn/14604-te…
hschallhorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,389 @@ | ||
# frozen_string_literal: true | ||
|
||
# Create distribution seeds to test priority push case distribution job. | ||
# Mocks previously distributed cases for judges. Sets up cases ready to be distributed. | ||
# Invoke with: | ||
# RequestStore[:current_user] = User.system_user | ||
# Dir[Rails.root.join("db/seeds/*.rb")].sort.each { |f| require f } | ||
# Seeds::PriorityDistributions.new.seed! | ||
|
||
module Seeds | ||
class PriorityDistributions < Base | ||
def seed! | ||
organize_judges | ||
create_previous_distribtions | ||
create_cases_tied_to_judges | ||
create_genpop_cases | ||
create_errorable_cases | ||
end | ||
|
||
private | ||
|
||
def organize_judges | ||
JudgeTeam.unscoped.find_by(name: "BVAACTING").inactive! | ||
JudgeTeam.find_by(name: "BVAAWAKEFIELD").update!(accepts_priority_pushed_cases: false) | ||
end | ||
|
||
def create_previous_distribtions | ||
judges_with_previous_distributions.each do |judge| | ||
2.times { create_priority_distribution_this_month(judge) } | ||
create_priority_distribution_last_month(judge) | ||
create_nonpriority_distribution_this_month(judge) | ||
end | ||
end | ||
|
||
def create_cases_tied_to_judges | ||
judges_with_tied_cases.each do |judge| | ||
create_legacy_cases_tied_to_judge(judge) | ||
create_hearing_cases_tied_to_judge(judge) | ||
end | ||
end | ||
|
||
def create_genpop_cases | ||
create_legacy_genpop_cases | ||
create_ama_hearing_genpop_cases | ||
create_direct_review_genpop_cases | ||
create_evidence_submission_genpop_cases | ||
end | ||
|
||
def create_errorable_cases | ||
create_legacy_appeal_with_previous_distribution | ||
end | ||
|
||
def create_legacy_cases_tied_to_judge(judge) | ||
create_legacy_ready_priority_cases_tied_to_judge(judge) | ||
create_legacy_nonready_priority_cases_tied_to_judge(judge) | ||
create_legacy_ready_nonpriority_cases_tied_to_judge(judge) | ||
end | ||
|
||
def create_hearing_cases_tied_to_judge(judge) | ||
create_hearing_ready_priority_cases_tied_to_judge(judge) | ||
create_hearing_nonready_priority_cases_tied_to_judge(judge) | ||
create_hearing_ready_nonpriority_cases_tied_to_judge(judge) | ||
end | ||
|
||
def create_legacy_genpop_cases | ||
create_legacy_ready_priority_genpop_cases | ||
create_legacy_ready_nonpriority_genpop_cases | ||
create_legacy_nonready_priority_genpop_cases | ||
end | ||
|
||
def create_ama_hearing_genpop_cases | ||
create_ama_hearing_ready_priority_genpop_cases | ||
create_ama_hearing_ready_nonpriority_genpop_cases | ||
create_ama_hearing_nonready_priority_genpop_cases | ||
end | ||
|
||
def create_direct_review_genpop_cases | ||
create_direct_review_ready_priority_genpop_cases | ||
create_direct_review_ready_nonpriority_genpop_cases | ||
create_direct_review_nonready_priority_genpop_cases | ||
end | ||
|
||
def create_evidence_submission_genpop_cases | ||
create_evidence_submission_ready_priority_genpop_cases | ||
create_evidence_submission_ready_nonpriority_genpop_cases | ||
create_evidence_submission_nonready_priority_genpop_cases | ||
end | ||
|
||
def create_priority_distribution_this_month(judge) | ||
create_unvalidated_completed_distribution( | ||
traits: [:priority, :this_month], | ||
judge: judge, | ||
statistics: { "batch_size" => rand(10) } | ||
) | ||
end | ||
|
||
def create_priority_distribution_last_month(judge) | ||
create_unvalidated_completed_distribution( | ||
traits: [:priority, :last_month], | ||
judge: judge, | ||
statistics: { "batch_size" => rand(10) } | ||
) | ||
end | ||
|
||
def create_nonpriority_distribution_this_month(judge) | ||
create_unvalidated_completed_distribution( | ||
traits: [:this_month], | ||
judge: judge, | ||
statistics: { "batch_size" => rand(10) } | ||
) | ||
end | ||
|
||
def create_legacy_ready_priority_cases_tied_to_judge(judge) | ||
rand(5).times do | ||
create( | ||
:case, | ||
:aod, | ||
:ready_for_distribution, | ||
:tied_to_judge, | ||
tied_judge: judge, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
end | ||
end | ||
|
||
def create_legacy_nonready_priority_cases_tied_to_judge(judge) | ||
rand(5).times do | ||
create( | ||
:case, | ||
:aod, | ||
:tied_to_judge, | ||
tied_judge: judge, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
end | ||
end | ||
|
||
def create_legacy_ready_nonpriority_cases_tied_to_judge(judge) | ||
rand(5).times do | ||
create( | ||
:case, | ||
:ready_for_distribution, | ||
:tied_to_judge, | ||
tied_judge: judge, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
end | ||
end | ||
|
||
def create_hearing_ready_priority_cases_tied_to_judge(judge) | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
:hearing_docket, | ||
:ready_for_distribution, | ||
hschallhorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:advanced_on_docket_due_to_age, | ||
:held_hearing, | ||
:tied_to_judge, | ||
tied_judge: judge, | ||
adding_user: User.first | ||
) | ||
end | ||
end | ||
|
||
def create_hearing_nonready_priority_cases_tied_to_judge(judge) | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
hschallhorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:hearing_docket, | ||
:with_post_intake_tasks, | ||
:advanced_on_docket_due_to_age, | ||
:held_hearing, | ||
:tied_to_judge, | ||
tied_judge: judge, | ||
adding_user: User.first | ||
) | ||
end | ||
end | ||
|
||
def create_hearing_ready_nonpriority_cases_tied_to_judge(judge) | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
:hearing_docket, | ||
:ready_for_distribution, | ||
:held_hearing, | ||
:tied_to_judge, | ||
tied_judge: judge, | ||
adding_user: User.first | ||
) | ||
end | ||
end | ||
|
||
def create_legacy_ready_priority_genpop_cases | ||
rand(50).times do | ||
create( | ||
:case, | ||
:aod, | ||
:ready_for_distribution, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
end | ||
end | ||
|
||
def create_legacy_nonready_priority_genpop_cases | ||
rand(5).times do | ||
create( | ||
:case, | ||
:aod, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
end | ||
end | ||
|
||
def create_legacy_ready_nonpriority_genpop_cases | ||
rand(5).times do | ||
create( | ||
:case, | ||
:ready_for_distribution, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
end | ||
end | ||
|
||
def create_ama_hearing_ready_priority_genpop_cases | ||
rand(50).times do | ||
create( | ||
:appeal, | ||
:hearing_docket, | ||
:ready_for_distribution, | ||
:advanced_on_docket_due_to_age, | ||
:held_hearing, | ||
adding_user: User.first | ||
) | ||
end | ||
end | ||
|
||
def create_ama_hearing_nonready_priority_genpop_cases | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
:hearing_docket, | ||
:with_post_intake_tasks, | ||
:advanced_on_docket_due_to_age, | ||
:held_hearing, | ||
adding_user: User.first | ||
) | ||
end | ||
end | ||
|
||
def create_ama_hearing_ready_nonpriority_genpop_cases | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
:hearing_docket, | ||
:ready_for_distribution, | ||
:held_hearing, | ||
adding_user: User.first | ||
) | ||
end | ||
end | ||
|
||
def create_direct_review_ready_priority_genpop_cases | ||
rand(50).times do | ||
create( | ||
:appeal, | ||
:direct_review_docket, | ||
:ready_for_distribution, | ||
:advanced_on_docket_due_to_age | ||
) | ||
end | ||
end | ||
|
||
def create_direct_review_nonready_priority_genpop_cases | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
:direct_review_docket, | ||
:with_post_intake_tasks, | ||
:advanced_on_docket_due_to_age | ||
) | ||
end | ||
end | ||
|
||
def create_direct_review_ready_nonpriority_genpop_cases | ||
rand(5).times do | ||
create( | ||
:appeal, | ||
:direct_review_docket, | ||
:ready_for_distribution | ||
) | ||
end | ||
end | ||
|
||
def create_evidence_submission_ready_priority_genpop_cases | ||
rand(10).times do | ||
FactoryBot.create( | ||
:appeal, | ||
:evidence_submission_docket, | ||
:ready_for_distribution, | ||
:advanced_on_docket_due_to_age | ||
) | ||
end | ||
end | ||
|
||
def create_evidence_submission_nonready_priority_genpop_cases | ||
rand(50).times do | ||
create( | ||
:appeal, | ||
:evidence_submission_docket, | ||
:with_post_intake_tasks, | ||
:advanced_on_docket_due_to_age | ||
) | ||
end | ||
end | ||
|
||
def create_evidence_submission_ready_nonpriority_genpop_cases | ||
rand(50).times do | ||
create( | ||
:appeal, | ||
:evidence_submission_docket, | ||
:ready_for_distribution | ||
) | ||
end | ||
end | ||
|
||
def create_legacy_appeal_with_previous_distribution | ||
vacols_case = create( | ||
:case, | ||
:aod, | ||
:ready_for_distribution, | ||
bfkey: random_key, | ||
correspondent: create(:correspondent, stafkey: random_key) | ||
) | ||
create(:legacy_appeal, :with_schedule_hearing_tasks, vacols_case: vacols_case) | ||
|
||
create_distribution_for_case_id(vacols_case.bfkey) | ||
end | ||
|
||
def create_distribution_for_case_id(case_id) | ||
create_unvalidated_completed_distribution( | ||
traits: [:priority, :completed, :this_month], | ||
judge: User.third, | ||
statistics: { "batch_size" => rand(10) } | ||
).distributed_cases.create( | ||
case_id: case_id, | ||
priority: case_id, | ||
docket: "legacy", | ||
ready_at: Time.zone.now, | ||
docket_index: "123", | ||
genpop: false, | ||
genpop_query: "any" | ||
) | ||
end | ||
|
||
def create_unvalidated_completed_distribution(attrs = {}) | ||
distribution = FactoryBot.build(:distribution, *attrs.delete(:traits), attrs) | ||
distribution.save!(validate: false) | ||
distribution.completed! | ||
distribution | ||
end | ||
|
||
def judges_with_tied_cases | ||
@judges_with_tied_cases ||= begin | ||
judges_with_judge_teams.unshift(User.find_by(full_name: "Steve Attorney_Cases Casper")) | ||
end | ||
end | ||
|
||
def judges_with_previous_distributions | ||
@judges_with_previous_distributions ||= begin | ||
judges_with_judge_teams.unshift(User.find_by(full_name: "Keith Judge_CaseToAssign_NoTeam Keeling")) | ||
end | ||
end | ||
|
||
def judges_with_judge_teams | ||
JudgeTeam.unscoped.map(&:judge) | ||
end | ||
|
||
def random_key | ||
rand.to_s[2..11] | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍳 🙆