Skip to content

Commit

Permalink
Merge branch 'master' into eileen/2075-multiple-judge-tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
eileen-nava committed Aug 10, 2021
2 parents e7288b3 + 64f6e7e commit 3561be1
Show file tree
Hide file tree
Showing 144 changed files with 69,179 additions and 1,722 deletions.
2 changes: 1 addition & 1 deletion .security.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CVES:
# placeholder to make non-nil array
CVE-no-such-number: 2020-01-01
CVE-2020-11023: 2021-08-06
CVE-2020-11023: 2021-08-16
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,4 @@ DEPENDENCIES
ziptz

BUNDLED WITH
2.2.19
2.2.25
1 change: 1 addition & 0 deletions app/assets/javascripts/explain-appeal-timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function groupEventItems(items){
content: 'cancelled<br/> tasks',
className: 'group_cancelled_tasks',
order: 3,
visible: false
});
groups.add({
id: 'others',
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/docs/v3/decision_reviews.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ components:
- Beneficiary Travel | Mileage
- Beneficiary Travel | Common Carrier
- Beneficiary Travel | Special Mode
- Caregiver
- Eligibility for Fee Basis Care
- Indebtedness | Validity of Debt
- Indebtedness | Waiver
Expand Down
23 changes: 19 additions & 4 deletions app/controllers/hearings/schedule_periods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def create
file_name = params["schedule_period"]["type"] + Time.zone.now.to_s + ".xlsx"
uploaded_file = Base64Service.to_file(params["schedule_period"]["file"], file_name)
S3Service.store_file(SchedulePeriod::S3_SUB_BUCKET + "/" + file_name, uploaded_file.tempfile, :filepath)
schedule_period = SchedulePeriod.create!(schedule_period_params.merge(user_id: current_user.id,
file_name: file_name))
render json: { id: schedule_period.id }
create_params = schedule_period_params.merge(user_id: current_user.id, file_name: file_name)

assign_hearing_days_or_create_schedule_period(create_params)
rescue StandardError => error
render(
json: {
Expand All @@ -51,7 +51,11 @@ def create

# Route to finalize and confirm a hearing schedule
def update
if schedule_period.can_be_finalized?
if params[:schedule_period_id] == "confirm_judge_assignments"
hearing_days = params["schedule_period"]
HearingSchedule::AssignJudgesToHearingDays.confirm_assignments(hearing_days)
render json: { success: true }
elsif schedule_period.can_be_finalized?
schedule_period.schedule_confirmed(schedule_period.algorithm_assignments)
render json: { id: schedule_period.id }
else
Expand Down Expand Up @@ -80,6 +84,17 @@ def download

private

def assign_hearing_days_or_create_schedule_period(create_params)
if params["schedule_period"]["type"] == "JudgeSchedulePeriod"
spreadsheet_data = HearingSchedule::AssignJudgesToHearingDays.load_spreadsheet_data(create_params["file_name"])
hearing_days = HearingSchedule::AssignJudgesToHearingDays.stage_assignments(spreadsheet_data)
render json: { hearing_days: hearing_days }
else
schedule_period = SchedulePeriod.create!(create_params)
render json: { id: schedule_period.id }
end
end

def schedule_period_params
params.require(:schedule_period).permit(:type, :start_date, :end_date)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Idt::Api::V1::UploadVbmsDocumentController < Idt::Api::V1::BaseController
end

def create
result = PrepareDocumentUploadToVbms.new(request.parameters).call
result = PrepareDocumentUploadToVbms.new(request.parameters, current_user).call

if result.success?
render json: { message: "Document successfully queued for upload." }
Expand Down
25 changes: 23 additions & 2 deletions app/jobs/upload_document_to_vbms_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@ class UploadDocumentToVbmsJob < CaseflowJob
queue_with_priority :low_priority
application_attr :idt

def perform(document_id:)
def perform(document_id:, initiator_css_id:)
RequestStore.store[:application] = "idt"
RequestStore.store[:current_user] = User.system_user

document = VbmsUploadedDocument.find_by(id: document_id)
@document = VbmsUploadedDocument.find_by(id: document_id)
@initiator = User.find_by_css_id(initiator_css_id)
add_context_to_sentry
UploadDocumentToVbms.new(document: document).call
end

private

attr_reader :document, :initiator

def add_context_to_sentry
if initiator.present?
Raven.user_context(
email: initiator.email,
css_id: initiator.css_id,
station_id: initiator.station_id,
regional_office: initiator.regional_office
)
end
Raven.extra_context(
vbms_uploaded_document_id: document.id,
case_details_path: "/queue/appeals/#{document.appeal.external_id}"
)
end
end
14 changes: 13 additions & 1 deletion app/mailers/hearing_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ def cancellation(email_recipient:, virtual_hearing: nil)

@recipient = email_recipient
@virtual_hearing = virtual_hearing
@hearing = virtual_hearing&.hearing

attachments[calendar_invite_name] = cancellation_calendar_invite

mail(
to: recipient.email,
subject: "Your Board hearing location has changed – Do Not Reply"
subject: cancellation_subject
)
end

Expand Down Expand Up @@ -71,6 +72,16 @@ def reminder(email_recipient:, virtual_hearing: nil, hearing: nil)

attr_reader :recipient, :virtual_hearing

def cancellation_subject
# :reek:RepeatedConditionals
case recipient.title
when HearingEmailRecipient::RECIPIENT_TITLES[:appellant]
"Your Board hearing will be held at #{@hearing.hearing_location_or_regional_office.name} – Do Not Reply"
when HearingEmailRecipient::RECIPIENT_TITLES[:representative]
"#{appellant_name}’s hearing will be held at #{@hearing.hearing_location_or_regional_office.name} – Do Not Reply"
end
end

def confirmation_calendar_invite
Hearings::CalendarService.confirmation_calendar_invite(virtual_hearing, recipient, link)
end
Expand Down Expand Up @@ -108,6 +119,7 @@ def reminder_subject
end

def confirmation_subject
# :reek:RepeatedConditionals
case recipient.title
when HearingEmailRecipient::RECIPIENT_TITLES[:appellant]
"Your Board hearing has been scheduled – Do Not Reply"
Expand Down
2 changes: 0 additions & 2 deletions app/models/appellant_substitution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def copy_request_issues(source_appeal, target_appeal)
# It may be better to copy specific attributes, than duplicate everything.
request_issue.dup.tap do |request_issue_copy|
request_issue_copy.decision_review = target_appeal
# Do not copy decisions for new appeal
request_issue_copy.decision_date = nil
request_issue_copy.save!
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/attorney_claimant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AttorneyClaimant < Claimant

delegate :name, to: :bgs_attorney

def advanced_on_docket?(_appeal_receipt_date)
def advanced_on_docket?(_appeal)
false
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/claimant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ class Claimant < CaseflowRecord
delegate :participant_id, to: :power_of_attorney, prefix: :representative, allow_nil: true

def self.create_without_intake!(participant_id:, payee_code:, type:)
create!(
claimant = create!(
participant_id: participant_id,
payee_code: payee_code,
type: type
)
Person.find_or_create_by_participant_id(participant_id)
claimant
end

def power_of_attorney
Expand Down
4 changes: 0 additions & 4 deletions app/models/concerns/task_tree_render_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
module TaskTreeRenderModule
PRESET_VALUE_FUNCS = {
CRE_DATE: ->(task) { task.created_at&.strftime("%Y-%m-%d") },
CRE_TIME: ->(task) { task.created_at&.strftime("%H-%M-%S") },
UPD_DATE: ->(task) { task.updated_at&.strftime("%Y-%m-%d") },
UPD_TIME: ->(task) { task.updated_at&.strftime("%H-%M-%S") },
CLO_DATE: ->(task) { task.closed_at&.strftime("%Y-%m-%d") },
CLO_TIME: ->(task) { task.closed_at&.strftime("%H-%M-%S") },
ASGN_DATE: ->(task) { task.assigned_at&.strftime("%Y-%m-%d") },
ASGN_TIME: ->(task) { task.assigned_at&.strftime("%H-%M-%S") },
ASGN_BY: lambda { |task|
ConsoleTreeRenderer.send_chain(task, [:assigned_by, :type])&.to_s ||
ConsoleTreeRenderer.send_chain(task, [:assigned_by, :name])&.to_s ||
Expand Down
5 changes: 4 additions & 1 deletion app/models/decision_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ def process!
upload_to_vbms!

if appeal.is_a?(Appeal)
create_board_grant_effectuations!
fail NotImplementedError if appeal.claimant.is_a?(OtherClaimant)

create_board_grant_effectuations!
# We do not want to process Board Grant Effectuations or create remand supplemental claims
# for appeals with unrecognized appellants because claim establishment
# in VBMS will fail due to the lack of a recognized claimant participant ID
process_board_grant_effectuations!
appeal.create_remand_supplemental_claims!
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/decision_review.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ def copy_claimants!(source_claimants)
# maintain the same ordering as used in the claimant method below so that claimant returns the correct one
source_claimants.order(:id).each_with_index do |claimant, index|
if index == 0
create_claimant!(
new_claimant = create_claimant!(
participant_id: claimant.participant_id,
payee_code: claimant.payee_code,
type: claimant.type
)
claimant.unrecognized_appellant&.copy_with_details(updated_claimant: new_claimant)
else
# Since create_claimant! removes all claimants, don't call it again
claimants.create_without_intake!(
Expand Down
6 changes: 1 addition & 5 deletions app/models/docket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ def self.nonpriority_decisions_per_year
private

def docket_appeals
Appeal.joins(:claimants)
.joins("left join unrecognized_appellants on claimants.id = unrecognized_appellants.claimant_id")
.where(docket_type: docket_type)
.where("unrecognized_appellants.id is null")
.extending(Scopes)
Appeal.where(docket_type: docket_type).extending(Scopes)
end

def assign_judge_tasks_for_appeals(appeals, judge)
Expand Down
2 changes: 2 additions & 0 deletions app/models/full_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def formatted(format)
case format
when :readable_full
[first_name, middle_initial, last_name].select(&:present?).join(" ").titleize
when :readable_full_nonformatted
[first_name, middle_initial, last_name].select(&:present?).join(" ")
when :readable_mi_formatted
[first_name, middle_initial + ".", last_name].select(&:present?).join(" ").titleize
when :readable_fi_last_formatted
Expand Down
19 changes: 7 additions & 12 deletions app/models/hearing_day.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HearingDayHasChildrenRecords < StandardError; end
SLOTS_BY_REQUEST_TYPE = {
REQUEST_TYPES[:virtual] => { default: 8, maximum: 12 },
REQUEST_TYPES[:central] => { default: 10, maximum: 10 },
REQUEST_TYPES[:video] => { default: 12, maximum: 12 }
REQUEST_TYPES[:video] => { default: 10, maximum: 10 }
}.freeze

DEFAULT_SLOT_LENGTH = 60 # in minutes
Expand Down Expand Up @@ -175,18 +175,9 @@ def slot_length_minutes
# - Date: from the scheduled_for column for this hearing_day
def begins_at
# If 'first_slot_time' column has a value, use that
unless first_slot_time.nil?
return combine_time_and_date(first_slot_time, "America/New_York", scheduled_for)
if first_slot_time.present?
combine_time_and_date(first_slot_time, "America/New_York", scheduled_for)
end

# if no value in db and central, 09:00
return combine_time_and_date("09:00", "America/New_York", scheduled_for) if central_office?

# if no value in db and virtual, 08:30
return combine_time_and_date("08:30", "America/New_York", scheduled_for) if virtual?

# if no value in db and video (not central or virtual): first_slot_time is 08:30
combine_time_and_date("08:30", RegionalOffice.find!(regional_office).timezone, scheduled_for)
end

def judge_first_name
Expand All @@ -197,6 +188,10 @@ def judge_last_name
judge ? judge.full_name.split(" ").last : nil
end

def judge_css_id
judge&.css_id
end

private

def assign_created_by_user
Expand Down
18 changes: 13 additions & 5 deletions app/models/hearings/forms/base_hearing_update_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ def show_update_alert?
end

def show_virtual_hearing_progress_alerts?
[appellant_email_sent_flag, representative_email_sent_flag, judge_email_sent_flag].any?(false)
[
virtual_hearing_updates[:appellant_email_sent],
virtual_hearing_updates[:representative_email_sent],
virtual_hearing_updates[:judge_email_sent]
].any?(false)
end

def should_create_or_update_virtual_hearing?
Expand Down Expand Up @@ -226,7 +230,7 @@ def update_appellant_recipient
update_params = {
email_address: appellant_email.presence,
timezone: virtual_hearing_updates[:appellant_tz].presence,
email_sent: virtual_hearing_updates[:appellant_email_sent]
email_sent: virtual_hearing_updates&.key?(:appellant_email_sent) ? false : true
}.compact

hearing.appellant_recipient.update!(**update_params) if update_params.any?
Expand All @@ -243,7 +247,7 @@ def update_representative_recipient
if hearing.representative_recipient.present?
update_params = {
timezone: virtual_hearing_updates[:representative_tz].presence,
email_sent: virtual_hearing_updates[:representative_email_sent]
email_sent: virtual_hearing_updates&.key?(:representative_email_sent) ? false : true
}.compact

hearing.representative_recipient.update!(**update_params) if update_params.any?
Expand All @@ -258,8 +262,12 @@ def update_judge_recipient
)
end

if virtual_hearing_updates.key?(:judge_email_sent)
hearing.judge_recipient.update!(email_sent: virtual_hearing_updates[:judge_email_sent])
if hearing.judge_recipient.present?
update_params = {
email_sent: virtual_hearing_updates&.key?(:judge_email_sent) ? false : true
}.compact

hearing.judge_recipient.update!(**update_params) if update_params.any?
end
end

Expand Down
23 changes: 4 additions & 19 deletions app/models/hearings/judge_non_availability.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# frozen_string_literal: true

class JudgeNonAvailability < NonAvailability
class << self
def import_judge_non_availability(schedule_period)
dates = HearingSchedule::GetSpreadsheetData.new(schedule_period.spreadsheet).judge_non_availability_data
judge_non_availability = []
judges = User.css_ids_by_vlj_ids(dates.pluck("vlj_id").uniq)
transaction do
dates.each do |date|
css_id = judges[date["vlj_id"]][:css_id]
date = (date["date"] == "N/A") ? nil : date["date"]
judge_non_availability << JudgeNonAvailability.create!(schedule_period: schedule_period,
date: date,
object_identifier: css_id)
end
end
judge_non_availability
end
end
end
##
# This class is no longer used, but preserved here to make it easier to access historical database records.
##
class JudgeNonAvailability < NonAvailability; end
6 changes: 5 additions & 1 deletion app/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ def friendly_description_for_codes(code_array)
# if there are more levels and codes there is the chance that issue description
# this shouldn't happen, but suspect this is happening and adding the log message.
if issue_description.is_a?(Hash)
Raven.capture_message("legacy appeal #{id} has an issue description that is a hash")
msg = "legacy appeal #{id} has an issue description that is a hash. "\
"This usually indicates a problem with the underlying data in VACOLS. Reach out to Jed via the dsva-vacols "\
"repo to determine if updating VACOLS data resolves the problem. For a prior example, see this ticket: "\
"https://github.com/department-of-veterans-affairs/dsva-vacols/issues/211"
Raven.capture_message(msg)
return ""
end

Expand Down
Loading

0 comments on commit 3561be1

Please sign in to comment.