diff options
author | Robert Speicher <robert@gitlab.com> | 2016-07-12 17:28:14 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-07-12 17:28:14 +0000 |
commit | 1ed89d376fc67ae50c5de2f538355fa6d1ab6d5b (patch) | |
tree | 4b786c68e858c5ab2a86bdf079effba44fcb0c96 /app/controllers | |
parent | aae8c9434f2a828e2dc9d027338928f91c7b0288 (diff) | |
parent | 244134f9c33dea0003dc2403dceace4b94a87d2e (diff) | |
download | gitlab-ce-1ed89d376fc67ae50c5de2f538355fa6d1ab6d5b.tar.gz |
Merge branch 'cache-todos-finder-calls' into 'master'
Cache todos pending/done dashboard query counts
See #19273
See merge request !5175
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 13 | ||||
-rw-r--r-- | app/controllers/projects/todos_controller.rb | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 3a2db3e6eeb..19a76a5b5d8 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -1,6 +1,4 @@ class Dashboard::TodosController < Dashboard::ApplicationController - include TodosHelper - before_action :find_todos, only: [:index, :destroy_all] def index @@ -13,7 +11,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController respond_to do |format| format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' } format.js { head :ok } - format.json { render json: { count: todos_pending_count, done_count: todos_done_count } } + format.json { render json: todos_counts } end end @@ -23,7 +21,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController respond_to do |format| format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' } format.js { head :ok } - format.json { render json: { count: todos_pending_count, done_count: todos_done_count } } + format.json { render json: todos_counts } end end @@ -36,4 +34,11 @@ class Dashboard::TodosController < Dashboard::ApplicationController def find_todos @todos ||= TodosFinder.new(current_user, params).execute end + + def todos_counts + { + count: TodosFinder.new(current_user, state: :pending).execute.count, + done_count: TodosFinder.new(current_user, state: :done).execute.count + } + end end diff --git a/app/controllers/projects/todos_controller.rb b/app/controllers/projects/todos_controller.rb index 23868d986e9..5685d0f4e7c 100644 --- a/app/controllers/projects/todos_controller.rb +++ b/app/controllers/projects/todos_controller.rb @@ -5,7 +5,7 @@ class Projects::TodosController < Projects::ApplicationController todo = TodoService.new.mark_todo(issuable, current_user) render json: { - count: current_user.todos_pending_count, + count: TodosFinder.new(current_user, state: :pending).execute.count, delete_path: dashboard_todo_path(todo) } end |