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

Mbeard/appeals 43118.4 #21529

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aa70145
Ricky/appeals-43523 (#21345)
Blake-Manus Apr 9, 2024
9cb3f1f
Merge branch 'master' into feature/APPEALS-40574
kristeja Apr 11, 2024
8a060eb
APPEALS-43116 add sentry error capture to push priority job and updat…
kristeja Apr 12, 2024
17481c7
init commit
mbeardy Apr 18, 2024
08afe53
fixes linting issues
mbeardy Apr 18, 2024
b3c4fcc
capybara test init
mbeardy Apr 18, 2024
24695f2
capybara test complete steps
mbeardy Apr 18, 2024
3331802
Ricky/appeals 43965 (#21431)
amybids Apr 22, 2024
e584ae5
Merge branch 'master' into feature/APPEALS-40574
amybids Apr 22, 2024
23d1e20
updates copy file with missing copy
mbeardy Apr 23, 2024
20c7af0
removes random changed files from push priority
mbeardy Apr 23, 2024
7ac3771
using different test methods find_field and find_button
mbeardy Apr 23, 2024
774c346
commented out test for now
mbeardy Apr 23, 2024
f9d75c9
APPEALS-43118 fixed merge conflict
amybids Apr 23, 2024
bad6fe0
added the raven command back
amybids Apr 23, 2024
4f87f2f
uncommented the frozen string literal comment to address the linting …
amybids Apr 23, 2024
177f5cf
mbeard/APPEALS-43118 (#21416)
mbeardy Apr 23, 2024
058a98f
Changed dockerfile to install node through NVM
sbashamoni Apr 25, 2024
c9fe300
Update env.sh with node 14.20 path
sbashamoni Apr 25, 2024
6faf06e
Removed unused node env
sbashamoni Apr 26, 2024
8aab190
APPEALS-40574 updating the route to only be in demo, local, and test
amybids Apr 26, 2024
640e345
Merge branch 'sbashamoni/APPEALS-44871-node14-demo-fixes' into featur…
amybids Apr 26, 2024
55252d9
Update Dockerfile Removed unused node env variable
sbashamoni Apr 29, 2024
337352a
Merge branch 'sbashamoni/APPEALS-44871-node14-demo-fixes' into featur…
amybids Apr 29, 2024
c3e6f80
Removed unused node env
sbashamoni Apr 29, 2024
005c07d
APPEALS-40574 removed the yarn node line as suggested by the system team
amybids Apr 29, 2024
a49fc91
added the latest node fix
amybids Apr 30, 2024
fd7079e
Merge branch 'feature/APPEALS-40574' of https://github.com/department…
mbeardy May 1, 2024
ecd38ca
Merge branch 'mbeard/APPEALS-43118.4' of https://github.com/departmen…
mbeardy May 1, 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
22 changes: 18 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ MAINTAINER Development and Operations team @ Department of Veterans Affairs
# Build variables
ENV BUILD build-essential postgresql-client libaio1 libpq-dev libsqlite3-dev curl software-properties-common apt-transport-https pdftk
ENV CASEFLOW git yarn
ENV NODE 14.20.0

# Environment (system) variables
ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH" \
Expand Down Expand Up @@ -34,16 +33,31 @@ COPY docker-bin/ca-certs/*.crt /usr/local/share/ca-certificates/va/
RUN update-ca-certificates
COPY docker-bin/ca-certs/cacert.pem /etc/ssl/certs/cacert.pem

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN apt -y update && \
apt -y upgrade && \
mkdir -p /usr/share/man/man1 && \
mkdir /usr/share/man/man7 && \
apt install -y ${BUILD} && \
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt -y update && \
apt-get install nodejs=${NODE} && \
apt install -y ${CASEFLOW} && \
apt -y update

#install node
RUN mkdir /usr/local/nvm
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 14.20.0
ENV NVM_INSTALL_PATH $NVM_DIR/versions/node/v$NODE_VERSION
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
RUN source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_INSTALL_PATH/lib/node_modules
ENV PATH $NVM_INSTALL_PATH/bin:$PATH

RUN apt install -y ${CASEFLOW} && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get clean && apt-get autoclean && apt-get autoremove
Expand Down
33 changes: 29 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ def case_distribution_url
}
end

def test_seeds_url
{
title: "Test Seeds",
link: "/test/seeds",
sort_order: 7
}
end

def hearing_application_url
{
title: "Hearings",
Expand Down Expand Up @@ -210,14 +218,31 @@ def manage_users_menu_item

def admin_menu_items
admin_urls = []
admin_urls.concat(manage_teams_menu_items) if current_user&.administered_teams&.any?
admin_urls.push(manage_users_menu_item) if current_user&.can_view_user_management?
admin_urls.push(case_distribution_url) if current_user&.organizations&.any?(&:users_can_view_levers?)
add_team_management_items(admin_urls)
add_user_management_items(admin_urls)
add_case_distribution_item(admin_urls)
add_test_seeds_item(admin_urls)

admin_urls.flatten
end

def add_team_management_items(admin_urls)
if current_user&.can_view_team_management? || current_user&.can_view_judge_team_management?
admin_urls.unshift(manage_all_teams_menu_item)
end
admin_urls.flatten
end

def add_user_management_items(admin_urls)
admin_urls.concat(manage_teams_menu_items) if current_user&.administered_teams&.any?
admin_urls.push(manage_users_menu_item) if current_user&.can_view_user_management?
end

def add_case_distribution_item(admin_urls)
admin_urls.push(case_distribution_url) if current_user&.organizations&.any?(&:users_can_view_levers?)
end

def add_test_seeds_item(admin_urls)
admin_urls.push(test_seeds_url) if current_user&.organizations&.any?(&:users_can_view_levers?)
end

def dropdown_urls
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/case_distribution_levers_tests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ def appeals_distributed
send_data csv_data, filename: filename
end

def ineligible_judge_list
# change this to the correct class
csv_data = IneligibleJudgeList.process

# Get the current date and time for dynamic filename
current_datetime = Time.zone.now.strftime("%Y%m%d-%H%M")

# Set dynamic filename with current date and time
filename = "#{current_datetime}_ineligible_judge_list.csv"

# Send CSV as a response with dynamic filename
send_data csv_data, filename: filename
end

private

def check_environment
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/concerns/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
module Errors
extend ActiveSupport::Concern
def invalid_role_error
render json: {
{
"errors": [
"title": "Role is Invalid",
"detail": "User is not allowed to perform this action"
]
}, status: :bad_request
],
"status": "bad_request"
}
end
end
8 changes: 7 additions & 1 deletion app/controllers/legacy_tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ def validate_user_id
end

def validate_user_role
return invalid_role_error unless ROLES.include?(user_role)
return true if ROLES.include?(user_role)

Rails.logger.info("User with roles #{current_user.roles.join(', ')} "\
"couldn't access #{request.original_url}: Error: #{invalid_role_error}")

session["return_to"] = request.original_url
redirect_to "/unauthorized"
end

def user
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/test/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Test::UsersController < ApplicationController
{
name: "Queue",
links: {
your_queue: "/queue"
your_queue: "/queue",
assignment_queue: "/queue/USER_CSS_ID/assign" # USER_CSS_ID is then updated in TestUsers file
}
},
{
Expand Down
61 changes: 61 additions & 0 deletions app/controllers/test_seeds_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

require "csv"

class TestSeedsController < ApplicationController
before_action :check_environment
before_action :verify_access, only: [:seeds]
before_action :authorize_admin, only: [:seeds]

def seeds
# seeds
render "/test/seeds"
end

def run_demo
seed_type = params[:seed_type].to_sym
seed_count = params[:seed_count].to_i
test_seed_list = Constants.TEST_SEEDS.to_h
task_name = test_seed_list[seed_type]

if task_name
Rake::Task[task_name].reenable
index = 0
seed_count.times do
index += 1
Rails.logger.info "Rake run count #{index}"
Rake::Task[task_name].execute
end
head :ok
else
render json: { error: "Invalid seed type" }, status: :bad_request
end
end

private

def check_environment
return true if Rails.env.development?
return true if Rails.deploy_env?(:demo)

redirect_to "/unauthorized"
end

def authorize_admin
error = ["UNAUTHORIZED"]

resp = {
status_code: 500,
message: error,
user_is_an_acd_admin: false
}
render json: resp unless CDAControlGroup.singleton.user_is_admin?(current_user)
end

def verify_access
return true if current_user&.organizations && current_user.organizations.any?(&:users_can_view_levers?)

session["return_to"] = request.original_url
redirect_to "/unauthorized"
end
end
1 change: 1 addition & 0 deletions app/jobs/push_priority_appeals_to_judges_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def perform
slack_msg = "<!here>\n [ERROR] after running for #{duration}: #{error.message}"
slack_service.send_notification(slack_msg, self.class.name)
log_error(error)
Raven.capture_exception(error, extra: { error_uuid: SecureRandom.uuid })
ensure
metrics_service_report_runtime(metric_group_name: "priority_appeal_push_job")
end
Expand Down
69 changes: 69 additions & 0 deletions app/queries/ineligible_judge_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

class IneligibleJudgeList
# define CSV headers and use this to pull fields to maintain order
HEADERS = {
caseflow_user_id: "Caseflow User ID",
satty_id: "satty ID",
judge_name: "Judge Name",
judge_css_id: "CSS ID",
judge_sdomain_id: "Judge SDomain ID",
reason_for_ineligibility: "Reason for Ineligibility"
}.freeze

EMPTY_KEY_VALUE = "No Key Present"
INACTIVE_VACOLS = CaseDistributionIneligibleJudges.ineligible_vacols_judges
INACTIVE_CASEFLOW = CaseDistributionIneligibleJudges.ineligible_caseflow_judges

def self.generate_rows(record)
HEADERS.keys.map { |key| record[key] }
end

def self.process
# Convert results to CSV format
CSV.generate(headers: true) do |csv|
# Add headers to CSV
csv << HEADERS.values

ineligible_judges = Rails.cache.fetch("case_distribution_ineligible_judges")
# Iterate through results and add each row to CSV
ineligible_judges.each do |record|
csv << generate_rows(parse_record(record))
end
end
end

def self.parse_record(record)
css_id_value = record.key?(:css_id) ? record[:css_id] : EMPTY_KEY_VALUE
sdomainid_value = record.key?(:sdomainid) ? record[:sdomainid] : EMPTY_KEY_VALUE

{
caseflow_user_id: record.key?(:id) ? record[:id] : nil,
satty_id: record.key?(:sattyid) ? record[:sattyid] : nil,
judge_name: get_judge_name(css_id_value, record[:sattyid]),
judge_css_id: css_id_value,
judge_sdomain_id: sdomainid_value,
reason_for_ineligibility: get_reason_for_ineligibility(css_id_value, sdomainid_value)
}
end

def self.get_reason_for_ineligibility(css_id_value, sdomainid_value)
@reason = if INACTIVE_CASEFLOW.find { |o| o[:css_id] == css_id_value }
if INACTIVE_VACOLS.find { |o| o[:sdomainid] == sdomainid_value }
"BOTH"
else
"CASEFLOW"
end
elsif INACTIVE_VACOLS.find { |o| o[:sdomainid] == sdomainid_value }
"VACOLS"
end
end

def self.get_judge_name(css_id_value, sattyid_value)
@judge_name = if css_id_value != EMPTY_KEY_VALUE && !css_id_value.nil?
User.find_by(css_id: css_id_value).full_name
elsif sattyid_value != EMPTY_KEY_VALUE && !sattyid_value.nil?
VACOLS::Staff.find_by(sattyid: sattyid_value).snamef
end
end
end
8 changes: 8 additions & 0 deletions app/views/test/seeds.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% content_for :full_page_content do %>
<%= react_component("TestSeeds", props: {
userDisplayName: current_user.display_name,
dropdownUrls: dropdown_urls,
applicationUrls: application_urls,
feedbackUrl: feedback_url
}) %>
<% end %>
4 changes: 3 additions & 1 deletion client/COPY.json
Original file line number Diff line number Diff line change
Expand Up @@ -1479,5 +1479,7 @@
"CASE_DISTRIBUTION_LEVER_HISTORY_DATA_ELEMENT": "Data Element Changed",
"CASE_DISTRIBUTION_LEVER_HISTORY_PREV_VALUE": "Previous Value",
"CASE_DISTRIBUTION_LEVER_HISTORY_UPDATED_VALUE": "Updated Value",
"CASE_DISTRIBUTION_STATIC_LEVERS_VALUES": "Values"
"CASE_DISTRIBUTION_STATIC_LEVERS_VALUES": "Values",
"TEST_SEEDS_ALERT_MESSAGE": " in progress",
"TEST_SEEDS_RUN_SEEDS": "Run Seed Files"
}
11 changes: 9 additions & 2 deletions client/app/caseDistribution/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,19 @@ class CaseDistributionTest extends React.PureComponent {
<ul>
<li>
<a href="/appeals-ready-to-distribute?csv=1">
<button className="btn btn-primary">Download Appeals Ready to Distribute CSV</button>
<Button classNames={['usa-button-active']}>
Download Appeals Ready to Distribute CSV
</Button>
</a>
</li>
<li>
<a href="/appeals-distributed?csv=1">
<button className="btn btn-primary">Download Distributed Appeals CSV</button>
<Button classNames={['usa-button-active']}>Download Distributed Appeals CSV</Button>
</a>
</li>
<li>
<a href="/ineligible-judge-list?csv=1">
<Button classNames={['usa-button-active']}>Download Ineligible Judge List</Button>
</a>
</li>
</ul>
Expand Down
4 changes: 3 additions & 1 deletion client/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import MPISearch from 'app/mpi/MPISearch';
import Admin from 'app/admin';
import CaseDistribution from 'app/caseDistribution';
import CaseDistributionTest from 'app/caseDistribution/test';
import TestSeeds from 'app/test/TestSeeds';
import uuid from 'uuid';

const COMPONENTS = {
Expand Down Expand Up @@ -95,7 +96,8 @@ const COMPONENTS = {
MPISearch,
Admin,
CaseDistribution,
CaseDistributionTest
CaseDistributionTest,
TestSeeds
};

const componentWrapper = (component) => (props, railsContext, domNodeId) => {
Expand Down
1 change: 1 addition & 0 deletions client/app/styles/caseDistribution/_case_distribution.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
@import '_batch_size.scss';
@import '_docket_time_goals.scss';
@import '_lever_buttons_wrapper.scss';
@import '_test_seeds.scss';
29 changes: 29 additions & 0 deletions client/app/styles/caseDistribution/_test_seeds.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.test-seeds-num-field {
width: auto;

.cf-form-int-input {
width: auto;
display: inline-block;
position: relative;

.input-container {
width: auto;
display: inline-block;
vertical-align: middle;
}

label {
position: absolute;
bottom: 6px;
left: 90px;
}
}
}

.test-seed-button-style {
button {
padding-top: 14px;
padding-bottom: 20px;
height: 45px;
}
}
Loading
Loading