-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add pagination to user queues #14242
Changes from all commits
fe83559
dcdcb73
b0bf1be
08fcd51
0d964de
704aadc
5cf38a1
93e1f6a
78bbd55
aab8fea
6eb17a9
9bb778d
9d04534
aa99bda
82590b1
9aea0a9
b46a11e
99a85ae
d794622
8d7d82e
e0fbe61
0ad1143
56e9531
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# shared code for controllers that paginate tasks. | ||
# requires methods: | ||
# * total_items | ||
# * allowed_params | ||
# | ||
module TaskPaginationConcern | ||
extend ActiveSupport::Concern | ||
|
||
def pagination_json | ||
{ | ||
tasks: json_tasks(task_pager.paged_tasks), | ||
task_page_count: task_pager.task_page_count, | ||
total_task_count: task_pager.total_task_count, | ||
tasks_per_page: TaskPager::TASKS_PER_PAGE | ||
} | ||
end | ||
|
||
private | ||
|
||
def task_pager | ||
@task_pager ||= TaskPager.new( | ||
assignee: assignee, | ||
tab_name: params[Constants.QUEUE_CONFIG.TAB_NAME_REQUEST_PARAM.to_sym], | ||
page: params[Constants.QUEUE_CONFIG.PAGE_NUMBER_REQUEST_PARAM.to_sym], | ||
sort_order: params[Constants.QUEUE_CONFIG.SORT_DIRECTION_REQUEST_PARAM.to_sym], | ||
sort_by: params[Constants.QUEUE_CONFIG.SORT_COLUMN_REQUEST_PARAM.to_sym], | ||
filters: params[Constants.QUEUE_CONFIG.FILTER_COLUMN_REQUEST_PARAM.to_sym] | ||
) | ||
end | ||
|
||
def json_tasks(tasks) | ||
tasks = AppealRepository.eager_load_legacy_appeals_for_tasks(tasks) | ||
params = { user: current_user } | ||
|
||
AmaAndLegacyTaskSerializer.new( | ||
tasks: tasks, params: params, ama_serializer: WorkQueue::TaskSerializer | ||
).call | ||
end | ||
end | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -42,7 +42,7 @@ def set_application | |||||||||||||||||||||||||||||||||||||||||||
# GET /tasks?user_id=xxx&role=attorney | ||||||||||||||||||||||||||||||||||||||||||||
# GET /tasks?user_id=xxx&role=judge | ||||||||||||||||||||||||||||||||||||||||||||
def index | ||||||||||||||||||||||||||||||||||||||||||||
tasks = QueueForRole.new(user_role).create(user: user).tasks | ||||||||||||||||||||||||||||||||||||||||||||
tasks = user.use_task_pages_api? ? [] : QueueForRole.new(user_role).create(user: user).tasks | ||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only improves the initial load time of a queue. Will file followup tickets to improve load times after creating or updating tasks. These tickets would remove caseflow/app/controllers/tasks_controller.rb Lines 71 to 83 in b0bf1be
caseflow/app/controllers/tasks_controller.rb Lines 95 to 102 in b0bf1be
and should exist outside of pagination |
||||||||||||||||||||||||||||||||||||||||||||
render json: { tasks: json_tasks(tasks), queue_config: queue_config } | ||||||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
class Users::TaskPagesController < UsersController | ||
include TaskPaginationConcern | ||
|
||
# /users/{user.id}/task_pages? | ||
# tab=on_hold& | ||
# sort_by=case_details_link& | ||
# order=desc& | ||
# filter[]=col%3Ddocket_type%26val%3Dlegacy& | ||
# filter[]=col%3Dtask_action%26val%3Dtranslation& | ||
# page=3 | ||
# | ||
# params = <ActionController::Parameters { | ||
# "tab"=>"on_hold", | ||
# "sort_by"=>"case_details_link", | ||
# "order"=>"desc", | ||
# "filter"=>[ | ||
# "col=docketNumberColumn&val=legacy,evidence_submission", | ||
# "col=taskColumn&val=Unaccredited rep,Extension" | ||
# ], | ||
# "page"=>"3" | ||
# }> | ||
|
||
def index | ||
render json: pagination_json | ||
end | ||
|
||
private | ||
|
||
def assignee | ||
user | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New controller for requesting paged tasks assigned to a user |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ def update | |
end | ||
|
||
def represented_organizations | ||
render json: { represented_organizations: User.find(params[:id]).vsos_user_represents } | ||
render json: { represented_organizations: User.find(id).vsos_user_represents } | ||
end | ||
|
||
def judge | ||
|
@@ -77,16 +77,20 @@ def filter_by_css_id_or_name | |
render json: { users: json_users(users) } | ||
end | ||
|
||
def id | ||
@id ||= params[:id] || params[:user_id] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could not for the life of me get a route were I could pass |
||
end | ||
|
||
def user | ||
unless css_id || params[:id] | ||
unless css_id || id | ||
fail( | ||
Caseflow::Error::InvalidParameter, | ||
parameter: "css_id or id", | ||
message: "Must provide a css id or user id" | ||
) | ||
end | ||
|
||
@user ||= params[:id] ? User.find(params[:id]) : User.find_by_css_id(css_id) | ||
@user ||= id ? User.find(id) : User.find_by_css_id(css_id) | ||
end | ||
|
||
def user_to_modify | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,10 +141,6 @@ def completed_tasks_tab | |
::OrganizationCompletedTasksTab.new(assignee: self, show_regional_office_column: show_regional_office_in_queue?) | ||
end | ||
|
||
def ama_task_serializer | ||
WorkQueue::TaskSerializer | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pulled out here |
||
|
||
private | ||
|
||
def clean_url | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ def attach_tasks_to_tab(tab) | |
# This allows us to only instantiate TaskPager if we are using the task pages API. | ||
task_page_count: task_pager.task_page_count, | ||
total_task_count: tab.tasks.count, | ||
task_page_endpoint_base_path: "#{assignee_is_org? ? "#{assignee.path}/" : ''}#{endpoint}" | ||
task_page_endpoint_base_path: "#{assignee_is_org? ? "#{assignee.path}/" : "users/#{assignee.id}/"}#{endpoint}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the endpoint the front end uses to request paged tasks |
||
) | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ def initialize(args) | |
end | ||
|
||
def paged_tasks | ||
sorted_tasks(filtered_tasks).page(page).per(TASKS_PER_PAGE) | ||
@paged_tasks ||= sorted_tasks(filtered_tasks).page(page).per(TASKS_PER_PAGE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
end | ||
|
||
def sorted_tasks(tasks) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,6 +285,10 @@ def administered_judge_teams | |
administered_teams.select { |team| team.is_a?(JudgeTeam) } | ||
end | ||
|
||
def non_administered_judge_teams | ||
organizations_users.non_admin.where(organization: JudgeTeam.all) | ||
end | ||
|
||
def user_info_for_idt | ||
self.class.user_repository.user_info_for_idt(css_id) | ||
end | ||
|
@@ -312,6 +316,10 @@ def judge? | |
!!JudgeTeam.for_judge(self) || judge_in_vacols? | ||
end | ||
|
||
def attorney? | ||
non_administered_judge_teams.any? || attorney_in_vacols? | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rely on user being on a judge team before checking vacols |
||
def update_status!(new_status) | ||
transaction do | ||
if new_status.eql?(Constants.USER_STATUSES.inactive) | ||
|
@@ -325,7 +333,7 @@ def update_status!(new_status) | |
end | ||
|
||
def use_task_pages_api? | ||
false | ||
FeatureToggle.enabled?(:user_queue_pagination, user: self) && !attorney? && !judge? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot paginate attorney or judge queues as they will have legacy tasks that are not persisted in the database. |
||
end | ||
|
||
def queue_tabs | ||
|
@@ -337,7 +345,7 @@ def queue_tabs | |
end | ||
|
||
def self.default_active_tab | ||
Constants.QUEUE_CONFIG.ASSIGNED_TASKS_TAB_NAME | ||
Constants.QUEUE_CONFIG.INDIVIDUALLY_ASSIGNED_TASKS_TAB_NAME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error from previous PRs |
||
end | ||
|
||
def assigned_tasks_tab | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ class AttorneyTaskListView extends React.PureComponent { | |
assignedTasks={this.props.workableTasks} | ||
onHoldTasks={this.props.onHoldTasks} | ||
completedTasks={this.props.completedTasks} | ||
requireDasRecord | ||
/> | ||
</AppSegment>; | ||
} | ||
|
@@ -86,8 +87,7 @@ const mapStateToProps = (state) => { | |
} | ||
}, | ||
ui: { | ||
messages, | ||
organizations | ||
messages | ||
} | ||
} = state; | ||
|
||
|
@@ -97,7 +97,6 @@ const mapStateToProps = (state) => { | |
completedTasks: completeTasksByAssigneeCssIdSelector(state), | ||
success: messages.success, | ||
error: messages.error, | ||
organizations, | ||
taskDecision | ||
}); | ||
}; | ||
|
@@ -124,7 +123,6 @@ AttorneyTaskListView.propTypes = { | |
resetErrorMessages: PropTypes.func, | ||
showErrorMessage: PropTypes.func, | ||
onHoldTasks: PropTypes.array, | ||
organizations: PropTypes.array, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Orgs was unused |
||
success: PropTypes.shape({ | ||
title: PropTypes.string, | ||
detail: PropTypes.string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,11 +50,9 @@ const mapStateToProps = (state) => { | |
|
||
return { | ||
success, | ||
organizations: state.ui.organizations, | ||
assignedTasks: newTasksByAssigneeCssIdSelector(state), | ||
onHoldTasks: onHoldTasksByAssigneeCssIdSelector(state), | ||
completedTasks: completeTasksByAssigneeCssIdSelector(state), | ||
queueConfig: state.queue.queueConfig | ||
completedTasks: completeTasksByAssigneeCssIdSelector(state) | ||
}; | ||
}; | ||
|
||
|
@@ -71,7 +69,5 @@ ColocatedTaskListView.propTypes = { | |
completedTasks: PropTypes.array, | ||
hideSuccessMessage: PropTypes.func, | ||
onHoldTasks: PropTypes.array, | ||
organizations: PropTypes.array, | ||
queueConfig: PropTypes.object, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. orgs and queue config were unused |
||
success: PropTypes.object | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled all this out of organization task pages controller to be reused in user task pages controller.