diff options
author | charlieablett <cablett@gitlab.com> | 2019-06-14 01:20:03 +0300 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-06-26 02:47:18 +0300 |
commit | 426f1c20b19e5bd98ee0ab8bd5f8851b683a79c6 (patch) | |
tree | 14dfe36a0f72fa5fee258f7a89f94c74be6720f4 /lib/api | |
parent | 4633df7b9e756ae50f35246e9ba93e1c3ca1e01a (diff) |
Remove N+1 query for project and group boards
- Add test for N+1 queries
- Add destroyable lists scope to Board and List
- Preload lists for both project and group boards
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/boards.rb | 2 | ||||
-rw-r--r-- | lib/api/boards_responses.rb | 2 | ||||
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/api/group_boards.rb | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/lib/api/boards.rb b/lib/api/boards.rb index b7c77730afb..4e31f74f18a 100644 --- a/lib/api/boards.rb +++ b/lib/api/boards.rb @@ -27,7 +27,7 @@ module API end get '/' do authorize!(:read_board, user_project) - present paginate(board_parent.boards), with: Entities::Board + present paginate(board_parent.boards.with_associations), with: Entities::Board end desc 'Find a project board' do diff --git a/lib/api/boards_responses.rb b/lib/api/boards_responses.rb index 86d9b24802f..68497a08fb8 100644 --- a/lib/api/boards_responses.rb +++ b/lib/api/boards_responses.rb @@ -11,7 +11,7 @@ module API end def board_lists - board.lists.destroyable + board.destroyable_lists end def create_list diff --git a/lib/api/entities.rb b/lib/api/entities.rb index ead01dc53f7..d783591c238 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1101,7 +1101,7 @@ module API expose :project, using: Entities::BasicProjectDetails expose :lists, using: Entities::List do |board| - board.lists.destroyable + board.destroyable_lists end end diff --git a/lib/api/group_boards.rb b/lib/api/group_boards.rb index 9a20ee8c8b9..feb2254963e 100644 --- a/lib/api/group_boards.rb +++ b/lib/api/group_boards.rb @@ -37,7 +37,7 @@ module API use :pagination end get '/' do - present paginate(board_parent.boards), with: Entities::Board + present paginate(board_parent.boards.with_associations), with: Entities::Board end end |