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

Remove old style hold code #12956

Merged
merged 13 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ def create
# {
# assigned_to_id: 23
# }
# To update colocated task
# e.g, for ama/legacy appeal => PATCH /tasks/:id,
# {
# status: :on_hold,
# on_hold_duration: "something"
# }
lomky marked this conversation as resolved.
Show resolved Hide resolved
def update
tasks = task.update_from_params(update_params, current_user)
tasks.each { |t| return invalid_record_error(t) unless t.valid? }
Expand Down Expand Up @@ -224,7 +218,6 @@ def create_params
def update_params
params.require("task").permit(
:status,
:on_hold_duration,
:assigned_to_id,
:instructions,
reassign: [:assigned_to_id, :assigned_to_type, :instructions],
Expand Down
2 changes: 1 addition & 1 deletion app/models/queues/generic_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(limit: 10_000, user:)
end

def tasks
(relevant_tasks + relevant_attorney_tasks).each(&:update_if_hold_expired!)
(relevant_tasks + relevant_attorney_tasks)
lomky marked this conversation as resolved.
Show resolved Hide resolved
end

private
Expand Down
11 changes: 1 addition & 10 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def calculated_placed_on_hold_at

def calculated_on_hold_duration
timed_hold_task = active_child_timed_hold_task
(timed_hold_task&.timer_end_time&.to_date &.- timed_hold_task&.timer_start_time&.to_date)&.to_i || on_hold_duration
(timed_hold_task&.timer_end_time&.to_date &.- timed_hold_task&.timer_start_time&.to_date)&.to_i
end

def update_task_type(params)
Expand Down Expand Up @@ -529,15 +529,6 @@ def timeline_title
"#{type} completed"
end

def update_if_hold_expired!
update!(status: Constants.TASK_STATUSES.in_progress) if old_style_hold_expired?
end

def old_style_hold_expired?
!on_timed_hold? && on_hold? && placed_on_hold_at && on_hold_duration &&
(placed_on_hold_at + on_hold_duration.days < Time.zone.now)
end

lomky marked this conversation as resolved.
Show resolved Hide resolved
def serializer_class
::WorkQueue::TaskSerializer
end
Expand Down
9 changes: 0 additions & 9 deletions app/models/tasks/hearing_admin_action_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class HearingAdminActionTask < Task
validates :parent, presence: true
validate :on_hold_duration_is_set, on: :update

def self.child_task_assignee(parent, params)
if params[:assigned_to_type] && params[:assigned_to_id]
Expand Down Expand Up @@ -48,14 +47,6 @@ def available_actions(user)
def actions_allowable?(user)
(HearingsManagement.singleton.user_has_access?(user) || HearingAdmin.singleton.user_has_access?(user)) && super
end

private

def on_hold_duration_is_set
if saved_change_to_status? && on_hold? && !on_hold_duration && !on_timed_hold? && assigned_to.is_a?(User)
errors.add(:on_hold_duration, "has to be specified")
end
end
lomky marked this conversation as resolved.
Show resolved Hide resolved
end

require_dependency "hearing_admin_action_contested_claimant_task"
Expand Down
3 changes: 1 addition & 2 deletions app/models/tasks/timed_hold_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class TimedHoldTask < Task
def self.create_from_parent(parent_task, days_on_hold:, assigned_by: nil, instructions: nil)
multi_transaction do
if parent_task.is_a?(Task)
# Set on_hold_duration to nil so that we override any old-style holds when we create a new timed hold.
parent_task.update_with_instructions(instructions: instructions, on_hold_duration: nil)
parent_task.update_with_instructions(instructions: instructions)
end
create!(
appeal: parent_task.appeal,
Expand Down
1 change: 0 additions & 1 deletion app/sql/ama-tasks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ SELECT
"Tasks"."appeal_type" AS TEXT
) AS "appeal_type"
,"Tasks"."placed_on_hold_at" AS "placed_on_hold_at"
,"Tasks"."on_hold_duration" AS "on_hold_duration"
,CAST (
"Tasks"."assigned_to_type" AS TEXT
) AS "assigned_to_type"
Expand Down
201 changes: 0 additions & 201 deletions client/app/queue/ColocatedPlaceHoldView.jsx

This file was deleted.

3 changes: 0 additions & 3 deletions client/app/queue/QueueApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import JudgeDecisionReviewTaskListView from './JudgeDecisionReviewTaskListView';
import JudgeAssignTaskListView from './JudgeAssignTaskListView';
import EvaluateDecisionView from './caseEvaluation/EvaluateDecisionView';
import AddColocatedTaskView from './AddColocatedTaskView';
import ColocatedPlaceHoldView from './ColocatedPlaceHoldView';
import CompleteTaskModal from './components/CompleteTaskModal';
import UpdateTaskStatusAssignRegionalOfficeModal from './components/UpdateTaskStatusAssignRegionalOfficeModal';
import CancelTaskModal from './components/CancelTaskModal';
Expand Down Expand Up @@ -203,8 +202,6 @@ class QueueApp extends React.PureComponent {

routedAddColocatedTask = (props) => <AddColocatedTaskView {...props.match.params} role={this.props.userRole} />;

routedColocatedPlaceHold = (props) => <ColocatedPlaceHoldView nextStep="/queue" {...props.match.params} />;

routedAdvancedOnDocketMotion = (props) => <AdvancedOnDocketMotionView {...props.match.params} />;

routedAssignToAttorney = (props) => <AssignToAttorneyModalView userId={this.props.userId} {...props.match.params} />;
Expand Down
4 changes: 0 additions & 4 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -876,15 +876,13 @@ def create_task_at_judge_review(appeal, judge, attorney)
def create_task_at_colocated(appeal, judge, attorney, trait = ColocatedTask.actions_assigned_to_colocated.sample.to_sym)
parent = FactoryBot.create(
:ama_judge_decision_review_task,
:on_hold,
assigned_to: judge,
appeal: appeal,
parent: create_root_task(appeal)
)

atty_task = FactoryBot.create(
:ama_attorney_task,
:on_hold,
assigned_to: attorney,
assigned_by: judge,
parent: parent,
Expand Down Expand Up @@ -914,7 +912,6 @@ def create_colocated_legacy_tasks(attorney)
def create_task_at_attorney_review(appeal, judge, attorney)
parent = FactoryBot.create(
:ama_judge_decision_review_task,
:on_hold,
assigned_to: judge,
appeal: appeal,
parent: create_root_task(appeal)
Expand Down Expand Up @@ -1008,7 +1005,6 @@ def create_task_at_bva_dispatch(seed = Faker::Number.number(digits: 3))
FactoryBot.create(:staff, :judge_role, user: judge)
judge_task = FactoryBot.create(
:ama_judge_decision_review_task,
:on_hold,
lomky marked this conversation as resolved.
Show resolved Hide resolved
assigned_to: judge,
appeal: appeal,
parent: root_task
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/asyncable_jobs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
create(:decision_document, submitted_at: 7.days.ago, attempted_at: 7.days.ago)
end
let!(:task_timer) do
task = create(:generic_task, :on_hold)
task = create(:generic_task)
TaskTimer.create!(task: task, submitted_at: 7.days.ago, attempted_at: 7.days.ago)
end

Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/tasks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
let!(:task12) { create(:ama_attorney_task, :in_progress, assigned_to: user) }
let!(:task13) { create(:ama_attorney_task, :completed, assigned_to: user) }
let!(:task16) { create(:ama_attorney_task, :completed_in_the_past, assigned_to: user) }
let!(:task14) { create(:ama_attorney_task, :on_hold, assigned_to: user) }
let!(:task14) { create(:ama_attorney_task, assigned_to: user) }

before { task3.update!(status: Constants.TASK_STATUSES.completed) }
before do
task3.update!(status: Constants.TASK_STATUSES.completed)
task14.update!(status: Constants.TASK_STATUSES.on_hold)
end

it "should process the request successfully" do
get :index, params: { user_id: user.id, role: "attorney" }
Expand Down Expand Up @@ -622,10 +625,7 @@
end

it "updates status to on_hold" do
patch :update, params: {
task: { status: Constants.TASK_STATUSES.on_hold, on_hold_duration: 60 },
id: admin_action.id
}
patch :update, params: { task: { status: Constants.TASK_STATUSES.on_hold }, id: admin_action.id }
expect(response.status).to eq 200
response_body = JSON.parse(response.body)["tasks"]["data"]
expect(response_body.first["attributes"]["status"]).to eq Constants.TASK_STATUSES.on_hold
Expand Down