diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-03-20 09:20:46 +0100 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-03-20 12:45:43 +0100 |
commit | bf41a2e7525cc952686623b508023c169dbdfe2d (patch) | |
tree | 54c40265696352d6972989dddd21d46f7c6ed9ae /app/finders | |
parent | 691402fb2b361ba19db3b8bdf77b75e513883423 (diff) | |
download | gitlab-ce-bf41a2e7525cc952686623b508023c169dbdfe2d.tar.gz |
Todos performance: Include associations in Finder
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/todos_finder.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb index b7f091f334d..13d33a1c31b 100644 --- a/app/finders/todos_finder.rb +++ b/app/finders/todos_finder.rb @@ -24,6 +24,7 @@ class TodosFinder def execute items = current_user.todos + items = include_associations(items) items = by_action_id(items) items = by_action(items) items = by_author(items) @@ -38,6 +39,17 @@ class TodosFinder private + def include_associations(items) + return items unless params[:include_associations] + + items.includes( + [ + target: { project: [:route, namespace: :route] }, + author: { namespace: :route }, + ] + ) + end + def action_id? action_id.present? && Todo::ACTION_NAMES.has_key?(action_id.to_i) end |