Skip to content

Commit

Permalink
Merge branch 'master' into ftseng/CASEFLOW-194-reminder-emails-job
Browse files Browse the repository at this point in the history
  • Loading branch information
va-bot committed Nov 16, 2020
2 parents 5663dae + b2be3f8 commit 31ffa4c
Show file tree
Hide file tree
Showing 95 changed files with 1,565 additions and 403 deletions.
24 changes: 10 additions & 14 deletions .circleci/config.yml
Expand Up @@ -184,7 +184,7 @@ jobs:

# This is the circleci provided Redis container.
- image: circleci/redis:4.0.10
parallelism: 9
parallelism: 12
resource_class: large
steps:
- attach_workspace:
Expand Down Expand Up @@ -212,17 +212,17 @@ jobs:
~/project/ci-bin/capture-log "bundle exec rake spec:setup_vacols"
- run:
name: RSpec
name: RSpec via knapsack_pro Queue Mode
command: |
mkdir -p ~/test-results/rspec
testfiles=$(circleci tests glob "spec/**/*spec.rb" | circleci tests split --split-by=timings)
echo $testfiles > ~/project/tmp/testfiles/rspec_testfiles.txt
~/project/ci-bin/capture-log "bundle exec rspec --no-color --format documentation --format RspecJunitFormatter -o ~/test-results/rspec/rspec.xml -- ${testfiles}"
# Uncomment to profile test performance in CircleCI
#environment:
# RDOC: 1
# RD_PROF: 1
# FPROF: 1
export RAILS_ENV=test
bundle exec rake "knapsack_pro:queue:rspec[--format documentation --no-color --format RspecJunitFormatter --out tmp/rspec.xml]"
environment:
KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
# Uncomment to profile test performance in CircleCI
# RDOC: 1
# RD_PROF: 1
# FPROF: 1

- store_test_results:
name: Store test results as summary
Expand All @@ -248,10 +248,6 @@ jobs:
name: Store bullet log
path: ~/project/log/bullet.log

- store_artifacts:
name: Store testfile ordering
path: ~/project/tmp/testfiles

- store_artifacts:
name: Store run logs
path: ~/logs
Expand Down
2 changes: 2 additions & 0 deletions .reek.yml
Expand Up @@ -89,6 +89,8 @@ detectors:
- FetchDocumentsForReaderJob#fetch_for_appeal
- FetchHearingLocationsForVeteransJob#sleep_before_retry_on_limit_error
- HearingSerializerBase
- HearingSchedule::GenerateHearingDaysSchedule#generate_co_hearing_days_schedule
- HearingSchedule::GenerateHearingDaysSchedule#get_fallback_date_for_co
- LegacyDocket#count
- RedistributedCase#legacy_appeal_relevant_tasks
- LegacyAppeal#cancel_open_caseflow_tasks!
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -103,6 +103,7 @@ group :test, :development, :demo do
gem "jshint", platforms: :ruby
gem "pry"
gem "pry-byebug"
gem "rails-erd"
gem "rb-readline"
gem "rspec"
gem "rspec-rails"
Expand All @@ -128,11 +129,11 @@ group :development do
gem "fasterer", require: false
gem "foreman"
gem "meta_request"
gem "rails-erd"
gem "ruby-prof", "~> 1.4"
end

group :test do
gem "knapsack_pro"
# For retrying failed feature tests. Read more: https://github.com/NoRedInk/rspec-retry
gem "rspec-retry"
gem "webmock"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -355,6 +355,8 @@ GEM
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
knapsack_pro (2.8.0)
rake
kramdown (2.3.0)
rexml
kramdown-parser-gfm (1.1.0)
Expand Down Expand Up @@ -698,6 +700,7 @@ DEPENDENCIES
jshint
json_schemer (~> 0.2.16)
kaminari
knapsack_pro
meta_request
moment_timezone-rails
multiverse
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,5 +1,5 @@
# Caseflow
[![CircleCI](https://circleci.com/gh/department-of-veterans-affairs/caseflow/tree/master.svg?style=svg)](https://circleci.com/gh/department-of-veterans-affairs/caseflow/tree/master)
[![CircleCI](https://circleci.com/gh/department-of-veterans-affairs/caseflow/tree/master.svg?style=svg)](https://circleci.com/gh/department-of-veterans-affairs/caseflow/tree/master) [![Knapsack Pro Parallel CI builds for Caseflow RSpec Tests](https://img.shields.io/badge/Knapsack%20Pro-Parallel%20%2F%20Caseflow%20RSpec%20Tests-%230074ff)](https://knapsackpro.com/dashboard/organizations/1654/projects/1260/test_suites/1783/builds?utm_campaign=organization-id-1654&utm_content=test-suite-id-1783&utm_medium=readme&utm_source=knapsack-pro-badge&utm_term=project-id-1260)

Caseflow is a suite of web-based tools to manage VA appeals. It's currently in development by the Appeals Modernization team (est. 2016). It will replace the current system of record for appeals, the Veterans Appeals Control and Location System (VACOLS), which was created in 1979 on now-outdated infrastructure. Additionally, Caseflow will allow the Board of Veterans' Appeals to process appeals under the new guidelines created by the Veterans Appeals Improvement and Modernization Act of 2017, which goes into effect February 14th, 2019.

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/intakes_controller.rb
Expand Up @@ -111,7 +111,8 @@ def index_props
covidTimelinessExemption: FeatureToggle.enabled?(:covid_timeliness_exemption, user: current_user),
verifyUnidentifiedIssue: FeatureToggle.enabled?(:verify_unidentified_issue, user: current_user),
attorneyFees: FeatureToggle.enabled?(:attorney_fees, user: current_user),
establishFiduciaryEps: FeatureToggle.enabled?(:establish_fiduciary_eps, user: current_user)
establishFiduciaryEps: FeatureToggle.enabled?(:establish_fiduciary_eps, user: current_user),
editEpClaimLabels: FeatureToggle.enabled?(:edit_ep_claim_labels, user: current_user)
}
}
rescue StandardError => error
Expand Down
1 change: 1 addition & 0 deletions app/controllers/tasks_controller.rb
Expand Up @@ -33,6 +33,7 @@ class TasksController < ApplicationController
PulacCerulloTask: PulacCerulloTask,
QualityReviewTask: QualityReviewTask,
ScheduleHearingTask: ScheduleHearingTask,
SendCavcRemandProcessedLetterTask: SendCavcRemandProcessedLetterTask,
SpecialCaseMovementTask: SpecialCaseMovementTask,
Task: Task,
TranslationTask: TranslationTask
Expand Down
12 changes: 6 additions & 6 deletions app/jobs/set_appeal_age_aod_job.rb
Expand Up @@ -30,21 +30,21 @@ def perform

def log_success(details)
duration = time_ago_in_words(start_time)
msg = "#{self.class.name} completed after running for #{duration}.\n#{details}"
Rails.logger.info(msg)
msg_title = "[INFO] #{self.class.name} completed after running for #{duration}."
Rails.logger.info("#{msg_title}\n#{details}")

slack_service.send_notification("[INFO] #{msg}")
slack_service.send_notification(details, msg_title)
end

def log_error(collector_name, err, details)
duration = time_ago_in_words(start_time)
msg = "#{collector_name} failed after running for #{duration}. Fatal error: #{err.message}.\n#{details}"
Rails.logger.info(msg)
msg_title = "[ERROR] #{collector_name} failed after running for #{duration}. Fatal error: #{err.message}."
Rails.logger.info("#{msg_title}\n#{details}")
Rails.logger.info(err.backtrace.join("\n"))

Raven.capture_exception(err, extra: { stats_collector_name: collector_name })

slack_service.send_notification("[ERROR] #{msg}")
slack_service.send_notification(details, msg_title)
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/stats_collector_job.rb
Expand Up @@ -96,7 +96,7 @@ def log_success
msg = "#{self.class.name} completed after running for #{duration}."
Rails.logger.info(msg)

slack_service.send_notification("[INFO] #{msg}") # may not need this
slack_service.send_notification("[INFO] #{msg}", self.class.to_s) # may not need this
end

def log_error(collector_name, err)
Expand All @@ -107,6 +107,6 @@ def log_error(collector_name, err)

Raven.capture_exception(err, extra: { stats_collector_name: collector_name })

slack_service.send_notification("[ERROR] #{msg}")
slack_service.send_notification("[ERROR] #{msg}", self.class.to_s)
end
end
2 changes: 1 addition & 1 deletion app/jobs/update_appellant_representation_job.rb
Expand Up @@ -101,7 +101,7 @@ def log_error(start_time, err)

Raven.capture_exception(err)

slack_service.send_notification("[ERROR] #{msg}")
slack_service.send_notification("[ERROR] #{msg}", self.class.to_s)

datadog_report_runtime(metric_group_name: METRIC_GROUP_NAME)
end
Expand Down
11 changes: 5 additions & 6 deletions app/jobs/update_cached_appeals_attributes_job.rb
Expand Up @@ -107,9 +107,8 @@ def cached_appeal_service
end

def log_warning
slack_msg = "[WARN] UpdateCachedAppealsAttributesJob first 100 warnings:"\
"\n#{warning_msgs.join("\n")}"
slack_service.send_notification(slack_msg)
slack_msg = warning_msgs.join("\n")
slack_service.send_notification(slack_msg, "[WARN] UpdateCachedAppealsAttributesJob: first 100 warnings")
end

def log_error(start_time, err)
Expand All @@ -121,9 +120,9 @@ def log_error(start_time, err)

Raven.capture_exception(err)

slack_msg = "[ERROR] UpdateCachedAppealsAttributesJob failed after running for #{duration}. "\
"See Sentry event #{Raven.last_event_id}"
slack_service.send_notification(slack_msg) # do not leak PII
slack_msg = "See Sentry event #{Raven.last_event_id}"
slack_service.send_notification(slack_msg,
"[ERROR] UpdateCachedAppealsAttributesJob failed after running for #{duration}.")

datadog_report_runtime(metric_group_name: METRIC_GROUP_NAME)
end
Expand Down
13 changes: 9 additions & 4 deletions app/models/appeal.rb
Expand Up @@ -27,12 +27,17 @@ class Appeal < DecisionReview
has_one :post_decision_motion
has_many :record_synced_by_job, as: :record
has_one :work_mode, as: :appeal
has_one :latest_informal_hearing_presentation_task, lambda {
not_cancelled
.order(closed_at: :desc, assigned_at: :desc)
.where(type: [InformalHearingPresentationTask.name, IhpColocatedTask.name], appeal_type: Appeal.name)
}, class_name: "Task", foreign_key: :appeal_id

enum stream_type: {
"original": "original",
"vacate": "vacate",
"de_novo": "de_novo",
"court_remand": "court_remand"
Constants.AMA_STREAM_TYPES.original.to_sym => Constants.AMA_STREAM_TYPES.original,
Constants.AMA_STREAM_TYPES.vacate.to_sym => Constants.AMA_STREAM_TYPES.vacate,
Constants.AMA_STREAM_TYPES.de_novo.to_sym => Constants.AMA_STREAM_TYPES.de_novo,
Constants.AMA_STREAM_TYPES.court_remand.to_sym => Constants.AMA_STREAM_TYPES.court_remand
}

after_create :conditionally_set_aod_based_on_age
Expand Down
8 changes: 6 additions & 2 deletions app/models/decision_review.rb
Expand Up @@ -347,9 +347,13 @@ def veteran_invalid_fields
end

def request_issues_ui_hash
request_issues.includes(
issues = request_issues.includes(
:decision_review, :contested_decision_issue
).active_or_ineligible_or_withdrawn.map(&:serialize)
)
active_issues = issues.active.sort_by { |issue| issue.end_product_establishment&.code }

# Sorts issues in the order that they appear on Add issues page, so that the numbering is sequential
[active_issues + issues.ineligible + issues.withdrawn].flatten.compact.map(&:serialize)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/end_product_establishment.rb
Expand Up @@ -315,7 +315,7 @@ def status
ep_code = Constants::EP_CLAIM_TYPES[code]
if committed?
{
ep_code: "#{modifier} #{ep_code ? ep_code['offical_label'] : 'Unknown'}",
ep_code: "#{modifier} #{ep_code ? ep_code['official_label'] : 'Unknown'}",
ep_status: [status_type, sync_status].compact.join(", ")
}
else
Expand Down
3 changes: 2 additions & 1 deletion app/models/end_product_update.rb
Expand Up @@ -48,7 +48,8 @@ def update_issue_type_to_nonrating
def update_issue_type_to_rating
request_issues.each do |ri|
ri.update(
type: "RatingRequestIssue"
type: "RatingRequestIssue",
edited_description: ri.nonrating_issue_description
)
end
end
Expand Down
13 changes: 13 additions & 0 deletions app/models/legacy_appeal.rb
Expand Up @@ -31,6 +31,11 @@ class LegacyAppeal < CaseflowRecord
has_many :claimants, -> { Claimant.none }
has_one :cached_vacols_case, class_name: "CachedAppeal", foreign_key: :vacols_id, primary_key: :vacols_id
has_one :work_mode, as: :appeal
has_one :latest_informal_hearing_presentation_task, lambda {
not_cancelled
.order(closed_at: :desc, assigned_at: :desc)
.where(type: [InformalHearingPresentationTask.name, IhpColocatedTask.name], appeal_type: LegacyAppeal.name)
}, class_name: "Task", foreign_key: :appeal_id
accepts_nested_attributes_for :worksheet_issues, allow_destroy: true

# Add Paper Trail configuration
Expand Down Expand Up @@ -387,6 +392,10 @@ def hearing_scheduled?
scheduled_hearings.any?
end

def any_held_hearings?
hearings.any?(&:held?)
end

def completed_hearing_on_previous_appeal?
vacols_ids = VACOLS::Case.where(bfcorlid: vbms_id).pluck(:bfkey)
hearings = HearingRepository.hearings_for_appeals(vacols_ids)
Expand Down Expand Up @@ -851,6 +860,10 @@ def cavc
type == "Court Remand"
end

def original?
type_code == "original"
end

alias cavc? cavc

# Adding anything to this to_hash can trigger a lazy load which slows down
Expand Down
2 changes: 1 addition & 1 deletion app/models/queue_tab.rb
Expand Up @@ -122,7 +122,7 @@ def on_hold_task_children_and_timed_hold_parents

def task_includes
[
{ appeal: [:available_hearing_locations, :claimants, :work_mode] },
{ appeal: [:available_hearing_locations, :claimants, :work_mode, :latest_informal_hearing_presentation_task] },
:assigned_by,
:assigned_to,
:children,
Expand Down
5 changes: 1 addition & 4 deletions app/models/serializers/v2/appeal_status_serializer.rb
Expand Up @@ -10,6 +10,7 @@ class V2::AppealStatusSerializer
set_id :appeal_status_id

attribute :appeal_ids, &:linked_review_ids
attribute :type

attribute :updated do
Time.zone.now.in_time_zone("Eastern Time (US & Canada)").round.iso8601
Expand All @@ -19,10 +20,6 @@ class V2::AppealStatusSerializer
false
end

attribute :type do
"original"
end

attribute :active, &:active_status?
attribute :description
attribute :aod, &:advanced_on_docket?
Expand Down
6 changes: 6 additions & 0 deletions app/models/serializers/work_queue/legacy_task_serializer.rb
Expand Up @@ -91,4 +91,10 @@ class WorkQueue::LegacyTaskSerializer
attribute :available_actions do |object, params|
object.available_actions_unwrapper(params[:user], params[:role])
end

attribute :latest_informal_hearing_presentation_task do |object|
task = object.appeal.latest_informal_hearing_presentation_task

task ? { requested_at: task.assigned_at, received_at: task.closed_at } : {}
end
end
10 changes: 10 additions & 0 deletions app/models/serializers/work_queue/task_column_serializer.rb
Expand Up @@ -248,6 +248,16 @@ def self.serialize_attribute?(params, columns)
end
end

attribute :latest_informal_hearing_presentation_task do |object, params|
columns = [Constants.QUEUE_CONFIG.COLUMNS.TASK_TYPE.name, Constants.QUEUE_CONFIG.COLUMNS.DAYS_WAITING.name]

if serialize_attribute?(params, columns)
task = object.appeal.latest_informal_hearing_presentation_task

task ? { requested_at: task.assigned_at, received_at: task.closed_at } : {}
end
end

# UNUSED

attribute :assignee_name do
Expand Down
10 changes: 6 additions & 4 deletions app/models/task.rb
Expand Up @@ -208,11 +208,13 @@ def joins_with_cached_appeals_clause
"and #{CachedAppeal.table_name}.appeal_type = #{Task.table_name}.appeal_type"
end

def order_by_appeal_priority_clause
def order_by_appeal_priority_clause(order: "asc")
boolean_order_clause = (order == "asc") ? "0 ELSE 1" : "1 ELSE 0"
Arel.sql(
"CASE WHEN #{CachedAppeal.table_name}.is_aod = TRUE THEN 0 ELSE 1 END, "\
"CASE WHEN #{CachedAppeal.table_name}.case_type = 'Court Remand' THEN 0 ELSE 1 END, "\
"#{Task.table_name}.created_at"
"CASE WHEN #{CachedAppeal.table_name}.is_aod = TRUE THEN #{boolean_order_clause} END, "\
"CASE WHEN #{CachedAppeal.table_name}.case_type = 'Court Remand' THEN #{boolean_order_clause} END, "\
"#{CachedAppeal.table_name}.docket_number #{order}, "\
"#{Task.table_name}.created_at #{order}"
)
end
end
Expand Down
8 changes: 1 addition & 7 deletions app/models/task_sorter.rb
Expand Up @@ -43,7 +43,7 @@ def sort_requires_case_norm?(col)
def order_clause
case column.name
when Constants.QUEUE_CONFIG.COLUMNS.APPEAL_TYPE.name
Arel.sql(appeal_type_order_clause)
Task.order_by_appeal_priority_clause(order: sort_order)
when Constants.QUEUE_CONFIG.COLUMNS.TASK_TYPE.name
Arel.sql(task_type_order_clause)
when Constants.QUEUE_CONFIG.COLUMNS.TASK_ASSIGNER.name
Expand Down Expand Up @@ -73,12 +73,6 @@ def task_type_order_clause
"position(#{task_type_sort_position}) #{sort_order}"
end

def appeal_type_order_clause
"cached_appeal_attributes.is_aod DESC, "\
"cached_appeal_attributes.case_type #{sort_order}, "\
"cached_appeal_attributes.docket_number #{sort_order}"
end

def assigner_order_clause
"substring(assigners.display_name,\'([a-zA-Z]+)$\') #{sort_order}"
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/tasks/cavc_task.rb
Expand Up @@ -12,7 +12,7 @@ class CavcTask < Task
before_validation :set_assignee

def self.label
"All CAVC-related tasks"
COPY::CAVC_TASK_LABEL
end

def available_actions(_user)
Expand Down

0 comments on commit 31ffa4c

Please sign in to comment.