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-46540: Reduce time to deploy demo environments #21791

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion app/controllers/test/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CaseflowCertification::Application.load_tasks

class Test::UsersController < ApplicationController
before_action :require_demo, only: [:set_user, :set_end_products, :reseed, :toggle_feature]
before_action :require_demo, only: [:set_user, :set_end_products, :reseed, :optional_seed, :toggle_feature]
before_action :require_global_admin, only: :log_in_as_user
skip_before_action :deny_vso_access, only: [:index, :set_user, :show]

Expand Down Expand Up @@ -110,6 +110,13 @@ def reseed
head :ok
end

def optional_seed
return unless Rails.deploy_env?(:demo)

system "bundle exec rake db:seed:optional"
head :ok
end

def toggle_feature
params[:enable]&.each do |f|
FeatureToggle.enable!(f[:value])
Expand Down
24 changes: 22 additions & 2 deletions client/app/test/TestUsers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default function TestUsers(props) {
const [isLoggingIn, setIsLoggingIn] = useState(false);
const [reseedingError, setReseedingError] = useState(null);
const [isReseeding, setIsReseeding] = useState(false);
const [optionalSeedingError, setOptionalSeedingError] = useState(null);
const [isOptionalSeeding, setIsOptionalSeeding] = useState(false);
const [inputValue, setInputValue] = useState('');

const handleEpSeed = (type) => ApiUtil.post(`/test/set_end_products?type=${type}`).
Expand Down Expand Up @@ -80,6 +82,18 @@ export default function TestUsers(props) {
});
};

const optionalSeed = () => {
setIsOptionalSeeding(true);
ApiUtil.post('/test/optional_seed').then(() => {
setOptionalSeedingError(null);
setIsOptionalSeeding(false);
}, (err) => {
console.warn(err);
setOptionalSeedingError(err);
setIsOptionalSeeding(false);
});
};

const filteredUserOptions = useMemo(() => {
const userOptions = props.testUsersList.map((user) => ({
value: user.id,
Expand Down Expand Up @@ -215,9 +229,9 @@ export default function TestUsers(props) {
Not all applications are available to every user. Additionally,
some users have access to different parts of the same application.
<br />This button reseeds the database with default values.</p>
{reseedingError &&
{(reseedingError || optionalSeedingError) &&
<Alert
message={reseedingError.toString()}
message={reseedingError ? reseedingError.toString() : optionalSeedingError.toString()}
type="error"
/>
}
Expand All @@ -226,6 +240,12 @@ export default function TestUsers(props) {
name="Reseed the DB"
loading={isReseeding}
loadingText="Reseeding the DB" />
<br />
<Button
onClick={optionalSeed}
name="Run optional seeds"
loading={isOptionalSeeding}
loadingText="Running optional seed" />
<br /> <br />
<h3>Global Feature Toggles Enabled:</h3>
<SearchableDropdown
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@
post "/set_user/:id", to: "users#set_user", as: "set_user"
post "/set_end_products", to: "users#set_end_products", as: 'set_end_products'
post "/reseed", to: "users#reseed", as: "reseed"
post "/optional_seed", to: "users#optional_seed", as: "optional_seed"
get "/data", to: "users#data"
end
post "/log_in_as_user", to: "users#log_in_as_user", as: "log_in_as_user"
Expand Down
38 changes: 3 additions & 35 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def call_and_log_seed_step(step)
Rails.logger.debug(msg)
end

# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def seed
RequestStore[:current_user] = User.system_user
call_and_log_seed_step :clean_db
Expand All @@ -43,49 +42,18 @@ def seed
# These must be ran before others
call_and_log_seed_step Seeds::BusinessLineOrg
call_and_log_seed_step Seeds::Users
call_and_log_seed_step Seeds::Veterans
call_and_log_seed_step Seeds::NotificationEvents
call_and_log_seed_step Seeds::CaseDistributionLevers
# End of required to exist dependencies
call_and_log_seed_step Seeds::Tasks
call_and_log_seed_step Seeds::Hearings
call_and_log_seed_step Seeds::Intake
call_and_log_seed_step Seeds::CavcSelectionBasisData
call_and_log_seed_step Seeds::CavcDecisionReasonData
call_and_log_seed_step Seeds::Dispatch
call_and_log_seed_step Seeds::Jobs
call_and_log_seed_step Seeds::Substitutions
call_and_log_seed_step Seeds::DecisionIssues
call_and_log_seed_step Seeds::CavcAmaAppeals
call_and_log_seed_step Seeds::SanitizedJsonSeeds
call_and_log_seed_step Seeds::VeteransHealthAdministration
call_and_log_seed_step Seeds::MTV
call_and_log_seed_step Seeds::Education
# Case Distribution Seed Data
# Creates 300+ priority cases ready for distribution
# Warning a number are not setup correctly so cannot be used beyond
# just distributing
call_and_log_seed_step Seeds::PriorityDistributions
call_and_log_seed_step Seeds::TestCaseData
call_and_log_seed_step Seeds::CaseDistributionAuditLeverEntries
# End of Case Distribution Seed Data
call_and_log_seed_step Seeds::Notifications
call_and_log_seed_step Seeds::CavcDashboardData
call_and_log_seed_step Seeds::VbmsExtClaim
call_and_log_seed_step Seeds::CasesTiedToJudgesNoLongerWithBoard
call_and_log_seed_step Seeds::VhaChangeHistory
call_and_log_seed_step Seeds::AmaAffinityCases
call_and_log_seed_step Seeds::BgsServiceRecordMaker
call_and_log_seed_step Seeds::MstPactLegacyCaseAppeals
call_and_log_seed_step Seeds::AmaIntake
# Always run this as last one
call_and_log_seed_step Seeds::StaticTestCaseData
call_and_log_seed_step Seeds::StaticDispatchedAppealsTestData
call_and_log_seed_step Seeds::RemandedAmaAppeals
call_and_log_seed_step Seeds::RemandedLegacyAppeals
call_and_log_seed_step Seeds::PopulateCaseflowFromVacols

Judge.list_all
Attorney.list_all
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
end

SeedDB.new.seed
2 changes: 1 addition & 1 deletion db/seeds/cases_tied_to_judges_no_longer_with_board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def find_or_create_inactive_judge(css_id, full_name)
end

def find_or_create_active_judge_with_only_sattyid(css_id, full_name)
User.find_by_css_id(css_id) || create(:user, :with_vacols_record, css_id: css_id, full_name: full_name)
User.find_by_css_id(css_id) || create(:user, :with_vacols_record_satty_id, css_id: css_id, full_name: full_name)
end

def inactive_cf_user_and_inactive_admin_judge_team
Expand Down
5 changes: 2 additions & 3 deletions db/seeds/cavc_ama_appeals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ def create_cavc_appeals_at_response_window
end

def create_cavc_appeals_at_response_window_complete
now = Time.zone.now
10.times do
Timecop.travel(now - 91.days)
Timecop.travel(91.days.ago)
appeal = create(:appeal, :cavc_response_window_open, veteran: create_veteran)
timed_hold_task = appeal.reload.tasks.find { |task| task.is_a?(TimedHoldTask) }
Timecop.travel(now)
Timecop.return
TaskTimerJob.new.send(:process, timed_hold_task.task_timers.first)
end
end
Expand Down
35 changes: 7 additions & 28 deletions db/seeds/intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
module Seeds
class Intake < Base
def seed!
create_intake_users
create_higher_level_review_tasks
create_higher_level_reviews_and_supplemental_claims
create_inbox_messages
Expand All @@ -17,40 +16,24 @@ def seed!

private

def create_intake_users
["Mail Intake", "Admin Intake"].each do |role|
# do not try to recreate when running seed file after inital seed
next if User.find_by_css_id("#{role.tr(' ', '')}_LOCAL".upcase)

create(:user,
css_id: "#{role.tr(' ', '')}_LOCAL",
roles: [role],
station_id: "101",
full_name: "Jame Local #{role} Smith")
end
end

def create_deceased_veteran
params = { first_name: "Ed", last_name: "Deceased", date_of_death: Time.zone.yesterday }
params[:file_number] = 45_454_545 unless Veteran.find_by(file_number: 45_454_545)
create(:veteran,
params)
create(:veteran, params)
end

def create_veteran_with_no_dependents
params = { first_name: "Robert", last_name: "Lonely" }
params[:file_number] = 44_444_444 unless Veteran.find_by(file_number: 44_444_444)
params[:participant_id] = 44_444_444 unless Veteran.find_by(file_number: 44_444_444)
create(:veteran,
params)
create(:veteran, params)
end

def create_deceased_veteran_with_no_dependents
params = { first_name: "Karen", last_name: "Lonely", date_of_death: Time.zone.yesterday }
params[:file_number] = 55_555_555 unless Veteran.find_by(file_number: 55_555_555)
params[:participant_id] = 55_555_555 unless Veteran.find_by(file_number: 55_555_555)
create(:veteran,
params)
create(:veteran, params)
end

def create_higher_level_review_tasks
Expand All @@ -70,9 +53,7 @@ def create_higher_level_review_tasks
decision_review: higher_level_review)
end
nca = BusinessLine.find_or_create_by(name: "National Cemetery Administration", url: "nca")
create(:higher_level_review_task,
assigned_to: nca,
appeal: higher_level_review)
create(:higher_level_review_task, assigned_to: nca, appeal: higher_level_review)
end
end

Expand Down Expand Up @@ -183,10 +164,7 @@ def create_higher_level_reviews_and_supplemental_claims
benefit_type: "compensation",
ineligible_reason: :untimely)

higher_level_review.create_issues!([
eligible_request_issue,
untimely_request_issue
])
higher_level_review.create_issues!([eligible_request_issue, untimely_request_issue])
higher_level_review.establish!

create(:supplemental_claim,
Expand Down Expand Up @@ -229,7 +207,8 @@ def create_inbox_messages
# rubocop:enable Metrics/MethodLength

def create_bgs_attorneys
5000.times { create(:bgs_attorney) } if BgsAttorney.count < 5000
attorneys_to_create = 1000 - BgsAttorney.count
attorneys_to_create.times { create(:bgs_attorney) } if attorneys_to_create > 0
end
end
end
86 changes: 29 additions & 57 deletions db/seeds/mtv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

module Seeds
class MTV < Base
MOTION_DISPOSITIONS = %w[denied dismissed granted].freeze
NOT_GRANTED_MOTION_DISPOSITIONS = %w[denied dismissed].freeze
VACATE_TYPES = %w[straight_vacate vacate_and_de_novo vacate_and_readjudication].freeze

def initialize
file_number_initial_value
end
Expand Down Expand Up @@ -117,71 +121,39 @@ def original_at_lit_support(mtv_judge, drafting_attorney)
end

def original_at_judge_to_address_motion(mtv_judge, drafting_attorney, lit_support_user)
# These are ready to be addressed by the Judge
3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "denied")
end

3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "dismissed")
end

3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted")
MOTION_DISPOSITIONS.each do |disposition|
# These are ready to be addressed by the Judge
3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, disposition)
end
end
end

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def vacate_at_attorney_review(mtv_judge, drafting_attorney, lit_support_user)
# These are ready to be reviewed by the decision drafting attorney on the vacate stream
3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "denied")
judge_addresses_mtv(jam_task, "denied", nil, lit_support_user)
end

3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "dismissed")
judge_addresses_mtv(jam_task, "dismissed", nil, lit_support_user)
end

3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted")
judge_addresses_mtv(jam_task, "granted", "straight_vacate", drafting_attorney)
end

3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted")
judge_addresses_mtv(jam_task, "granted", "vacate_and_readjudication", drafting_attorney)
NOT_GRANTED_MOTION_DISPOSITIONS.each do |disposition|
# These are ready to be reviewed by the decision drafting attorney on the vacate stream
3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, disposition)
judge_addresses_mtv(jam_task, disposition, nil, lit_support_user)
end
end

3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted")
judge_addresses_mtv(jam_task, "granted", "vacate_and_de_novo", drafting_attorney)
VACATE_TYPES.each do |vacate_type|
3.times do
original_stream = create_decided_appeal(mtv_judge, drafting_attorney)
mtv_task = create_motion_to_vacate_mail_task(original_stream)
mtv_task.update!(status: "on_hold")
jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted")
judge_addresses_mtv(jam_task, "granted", vacate_type, drafting_attorney)
end
end
end
# rubocop:enable Metrics/MethodLength
Expand Down
Loading
Loading