Commit 693d3c8d authored by charlie ablett's avatar charlie ablett

Use Keyset pagination

- Apply reviewer feedback
parent 0e825e45
......@@ -9,7 +9,7 @@ module Resolvers
def resolve(**args)
# rubocop: disable CodeReuse/ActiveRecord
service = Boards::Issues::ListService.new(list.board.resource_parent, context[:current_user], { board_id: list.board.id, id: list.id })
Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection.new(service.execute)
service.execute.reorder("issues.relative_position ASC, issues.id DESC")
# rubocop: enable CodeReuse/ActiveRecord
end
end
......
......@@ -7,7 +7,7 @@ module Types
description: 'Total count of collection'
def count
relation = object.items.reorder(nil)
relation = object.items
if relation.try(:group_values)&.present?
relation.size.keys.size
......
......@@ -20,17 +20,12 @@ RSpec.describe Resolvers::BoardListIssuesResolver do
# auth is handled by the parent object
context 'when authorized' do
let!(:list) { create(:list, board: board, label: label) }
let!(:issue1) { create(:issue, project: project, labels: [label], relative_position: 10, id: 44) }
let!(:issue2) { create(:issue, project: project, labels: [label], relative_position: 12, id: 45) }
let!(:issue3) { create(:issue, project: project, labels: [label], relative_position: 10, id: 46) }
it 'calls Boards::Issues::ListService with the correct arguments' do
expect(Boards::Issues::ListService).to receive(:new).with(board_parent, user, { board_id: board.id, id: list.id }).and_call_original
resolve_board_list_issues
end
it 'returns the issues in the correct order' do
issue1 = create(:issue, project: project, labels: [label], relative_position: 10)
issue2 = create(:issue, project: project, labels: [label], relative_position: 12)
issue3 = create(:issue, project: project, labels: [label], relative_position: 10)
# by relative_position and then ID
issues = resolve_board_list_issues
......
......@@ -51,10 +51,10 @@ RSpec.describe 'get board lists' do
shared_examples 'group and project board list issues query' do
let!(:board) { create(:board, resource_parent: board_parent) }
let!(:label_list) { create(:list, board: board, label: label, position: 10) }
let!(:issue1) { create(:issue, project: issue_project, labels: [label], relative_position: 9, id: 10) }
let!(:issue2) { create(:issue, project: issue_project, labels: [label], relative_position: 2, id: 11) }
let!(:issue3) { create(:issue, project: issue_project, labels: [label], relative_position: 9, id: 12) }
let!(:issue4) { create(:issue, project: issue_project, labels: [label2], relative_position: 432, id: 13) }
let!(:issue1) { create(:issue, project: issue_project, labels: [label], relative_position: 9) }
let!(:issue2) { create(:issue, project: issue_project, labels: [label], relative_position: 2) }
let!(:issue3) { create(:issue, project: issue_project, labels: [label], relative_position: 9) }
let!(:issue4) { create(:issue, project: issue_project, labels: [label2], relative_position: 432) }
context 'when the user does not have access to the board' do
it 'returns nil' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment