Skip to content

Commit

Permalink
Merge branch 'feature/APPEALS-49620' into b_reed/APPEALS-65696
Browse files Browse the repository at this point in the history
  • Loading branch information
breedbah committed Nov 25, 2024
2 parents ca90f9a + 59ae659 commit 5f01434
Show file tree
Hide file tree
Showing 36 changed files with 1,443 additions and 529 deletions.
3 changes: 2 additions & 1 deletion app/controllers/decision_reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def index
respond_to do |format|
format.html { render "index" }
format.csv do
jobs_as_csv = BusinessLineReporter.new(business_line).as_csv
filter_params = allowed_params[Constants.QUEUE_CONFIG.FILTER_COLUMN_REQUEST_PARAM.to_sym]
jobs_as_csv = BusinessLineReporter.new(business_line, filter_params).as_csv
send_data jobs_as_csv, filename: csv_filename
end
format.json { queue_tasks }
Expand Down
65 changes: 65 additions & 0 deletions app/models/organizations/business_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def build_query
.from(combined_decision_review_tasks_query)
.includes(*decision_review_task_includes)
.where(task_filter_predicate(query_params[:filters]))
.where(closed_at_filter_predicate(query_params[:filters]))
.order(order_clause)
end

Expand Down Expand Up @@ -1082,6 +1083,70 @@ def locate_issue_type_filter(filters)
def where_clause_from_array(table_class, column, values_array)
table_class.arel_table[column].in(values_array)
end

def closed_at_filter_predicate(filters)
return "" if filters.blank?

closed_at_filter = locate_closed_at_filter(filters)

return "" unless closed_at_filter

# ex: "val"=> val=[before,2024-09-08,]
closed_at_params = closed_at_filter["val"].first.split(",")

build_closed_at_filter_predicate(closed_at_params) || ""
end

def locate_closed_at_filter(filters)
parsed_filters = parse_filters(filters)

parsed_filters.find do |filter|
filter["col"].include?("completedDateColumn")
end
end

def build_closed_at_filter_predicate(closed_at_params)
return "" if closed_at_params.blank?

mode, start_date, end_date = closed_at_params
operator = date_filter_mode_to_operator(mode)

# Break early if start date is not present and it's not one of these 3 filter types
return "" if !%w[last_7_days last_30_days last_365_days].include?(operator) && start_date.blank?

date_filter_lambda_hash(start_date, end_date).fetch(operator, lambda {
Rails.logger.error("Unsupported mode **#{operator}** used for closed at date filtering")
""
}).call
end

def date_filter_lambda_hash(start_date, end_date)
{
">" => -> { "tasks.closed_at::date > '#{start_date}'::date" },
"<" => -> { "tasks.closed_at::date < '#{start_date}'::date" },
"=" => -> { "tasks.closed_at::date = '#{start_date}'::date" },
"between" => lambda {
# Ensure the dates are sorted correctly so either ordering works e.g. start > end or end > start
start_date, end_date = [start_date, end_date].map(&:to_date).sort
end_date ? "tasks.closed_at::date BETWEEN '#{start_date}'::date AND '#{end_date}'::date" : ""
},
"last_7_days" => -> { { closed_at: 1.week.ago..Time.zone.now } },
"last_30_days" => -> { { closed_at: 30.days.ago..Time.zone.now } },
"last_365_days" => -> { { closed_at: 365.days.ago..Time.zone.now } }
}
end

def date_filter_mode_to_operator(mode)
{
"between" => "between",
"after" => ">",
"before" => "<",
"on" => "=",
"last7" => "last_7_days",
"last30" => "last_30_days",
"last365" => "last_365_days"
}[mode]
end
end
# rubocop:enable Metrics/ClassLength
end
2 changes: 1 addition & 1 deletion app/models/organizations/vha_business_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def tasks_query_type
{
incomplete: "on_hold",
in_progress: "active",
completed: "recently_completed",
completed: "completed",
pending: "active"
}
end
Expand Down
18 changes: 13 additions & 5 deletions app/services/business_line_reporter.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
# frozen_string_literal: true

class BusinessLineReporter
attr_reader :business_line
attr_reader :business_line, :filters

BUSINESS_LINE_OPTIONS = %w[business_line appeal_id appeal_type claimant_name request_issues_count
decision_issues_count veteran_file_number intake_user_id
task_type task_id tasks_url task_assigned_to created_at closed_at].freeze

def initialize(business_line)
def initialize(business_line, filters = nil)
@business_line = business_line
@filters = { filters: filters, sort_by: :id, sort_order: :asc }
end

def tasks
business_line.tasks.completed.includes(
[:assigned_to, appeal: [:request_issues, :decision_issues, intake: [:user]]]
).order(id: :asc)
# If it is the VhaBusinessLine use the decision review queue task methods since they support the filters
if business_line.is_a?(VhaBusinessLine)
business_line.completed_tasks(filters).includes(
[:assigned_to, appeal: [:request_issues, :decision_issues, intake: [:user]]]
)
else
business_line.tasks.completed.includes(
[:assigned_to, appeal: [:request_issues, :decision_issues, intake: [:user]]]
).order(id: :asc)
end
end

# rubocop:disable Metrics/AbcSize
Expand Down
10 changes: 8 additions & 2 deletions client/COPY.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@
"ORGANIZATIONAL_QUEUE_PAGE_ASSIGNED_TAB_TITLE": "Assigned (%d)",
"ORGANIZATIONAL_QUEUE_PAGE_IN_PROGRESS_TAB_TITLE": "In Progress (%d)",
"ORGANIZATIONAL_QUEUE_ON_HOLD_TAB_TITLE": "On Hold (%d)",
"VHA_QUEUE_PAGE_COMPLETE_TASKS_DESCRIPTION": "Cases completed:",
"VHA_QUEUE_PAGE_COMPLETE_TASKS_DESCRIPTION": "Cases completed",
"VHA_QUEUE_PAGE_COMPLETE_TASKS_DESCRIPTION_WITH_FILTER": "Cases completed (%s)",
"EDUCATION_RPO_QUEUE_PAGE_COMPLETED_TASKS_DESCRIPTION": "Cases completed in the last 7 days:",
"VHA_ORGANIZATIONAL_QUEUE_PAGE_READY_FOR_REVIEW_TAB_TITLE": "Ready for Review",
"VHA_ORGANIZATIONAL_QUEUE_PAGE_ON_HOLD_TAB_TITLE": "On Hold",
Expand Down Expand Up @@ -1615,11 +1616,16 @@
"DATE_PICKER_CLEAR": "Clear filter",
"DATE_PICKER_DROPDOWN_LABEL": "Date filter parameters",
"DATE_PICKER_QUICK_BUTTON_30": "Last 30 days",
"DATE_PICKER_DROPDOWN_7": "Last 7 days",
"DATE_PICKER_DROPDOWN_30": "Last 30 days",
"DATE_PICKER_DROPDOWN_365": "Last 365 days",
"DATE_PICKER_DROPDOWN_ALL": "View All",
"DATE_PICKER_NO_FUTURE_DATES_ERROR_MESSAGE": "Date cannot be in the future.",
"DATE_PICKER_BETWEEN_DATES_ERROR_MESSAGE": "\"To\" date cannot occur before the \"From\" date",
"WORK_ORDER_BANNER_MESSAGE": "Work Order Transcription Package will need to be manually removed from the box.com folder for %s, please inform %s as they may have picked up the Work Order",
"HEARING_BANNER_MESSAGE": "All Hearing files have been set back to the UnAssigned state for Dispatching",
"UPLOAD_TRANSCRIPTION_VBMS_TEXT": "By uploading to VBMS, you are confirming that you have reviewed the transcript in Caseflow and have found no errors.",
"UPLOAD_TRANSCRIPTION_VBMS_TEXT_AREA": "Please provide context and instructions for this action",
"UPLOAD_TRANSCRIPTION_VBMS_TITLE": "Upload transcript to VBMS",
"UPLOAD_TRANSCRIPTION_VBMS_BUTTON": "Upload to VBMS"

}
Loading

0 comments on commit 5f01434

Please sign in to comment.