-
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
[PART 1] Add task pagination endpoint for user tasks #14252
[PART 1] Add task pagination endpoint for user tasks #14252
Conversation
Code Climate has analyzed commit b9cf987 and detected 0 issues on this pull request. View more on Code Climate. |
tasks: tasks, params: params, ama_serializer: WorkQueue::TaskSerializer | ||
).call | ||
end | ||
end |
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 out of app/controllers/organizations/task_pages_controller.rb to be reused in app/controllers/users/task_pages_controller.rb
def ama_task_serializer | ||
WorkQueue::TaskSerializer | ||
end | ||
|
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
URL the front end will use to request paged tasks
resources :users, only: [:index, :update] | ||
resources :users, only: [:index] do | ||
resources :users, only: [:index, :update] do | ||
resources :task_pages, only: [:index], controller: 'users/task_pages' |
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.
New route for the pagination of user tasks
allow_any_instance_of(::Organizations::TaskPagesController).to receive(:json_tasks).and_return([]) | ||
|
||
subject | ||
end |
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 out into spec/controllers/paged_tasks_shared_examples.rb
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.
Left some suggestions.
Also manually tested:
- the sum of
tasks.count
equals theresponse_body["total_task_count"]
- other filters work
- bad filter returns empty list
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.
Good to go! 🥇
Generated by 🚫 Danger |
THIS PR
Part 1 of stack to speed up user queues and bump #14142
Part 2
Description
Creates an endpoint to request the paged tasks of a user
AC
Testing
THE FULL STACK
spoilers!
Part 2 of stack to bump #14142 [Part 1](https://github.com//pull/14252)Description
Allows user queues to be paginated
Testing
Initial queue load only loads first page of tasks
With dev tools open, got to the user's queue
total_task_count
andtask_page_count
are correcttasks: { data: [] }
Filtering, sorting, paging, and switching tabs work
Try a combination of filtering and sorting to confirm the correct tasks are show. Bonus points for trying the same combination more than once and noticing the loading page is not shown because we're pulling from cached results. Each request should only return 15 tasks.
Sorting
Filtering
Paging
Changing tabs
Any combinations of the above
?tab=INVALID_TAB_NAME
?tab=unassigned_person&page=1
?tab=assigned_person&page=20
?tab=assigned_person&page=1
?tab=assigned_person&page=-12
?tab=assigned_person&page=1
?tab=assigned_person&page=1&sort_by=INVALID_COLUMN
?tab=assigned_person&page=1
?tab=assigned_person&page=1&sort_by=taskColumn&order=INVALID_SORT_ORDER
?tab=assigned_person&page=1&sort_by=taskColumn&order=asc
(Notice the sort order is defaulted to asc)?tab=assigned_person&page=1&filter%5B%5D=col%3DINVALID_COLUMN_NAME%26val%3DAojColocatedTask
?tab=assigned_person&page=1
?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DINVALID_FILTER_VALUE
?tab=assigned_person&page=1
?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DAojColocatedTask%7CINVALID_FILTER_VALUE
?tab=assigned_person&page=1&filter%5B%5D=col%3DtaskColumn%26val%3DAojColocatedTask
(Notice correct filter is preserved)THINGS THAT SHOULD NOT HAVE CHANGED