summaryrefslogtreecommitdiff
path: root/app/controllers/dashboard
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-06-02 15:46:58 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-06-17 19:04:36 +0200
commitf6bfa46daae3a00ca6f74abb6e6eddc9eac96197 (patch)
treee80a1c3cde48387c034dbec51636b8d2c5277873 /app/controllers/dashboard
parentfcd9f90641d5ee59cc84d8388b7cc372370ac25a (diff)
downloadgitlab-ce-f6bfa46daae3a00ca6f74abb6e6eddc9eac96197.tar.gz
Cache todo counters (pending/done)18034-cache-todo-counter
- As todos are created/updated inside the TodoService we repopulate the cache just there for both pending/done todos - Todos as mark as done from the TodosController we update cache there too - All the added methods are kept in the User class for cohesion
Diffstat (limited to 'app/controllers/dashboard')
-rw-r--r--app/controllers/dashboard/todos_controller.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb
index f9a1929c117..7842fb9ce63 100644
--- a/app/controllers/dashboard/todos_controller.rb
+++ b/app/controllers/dashboard/todos_controller.rb
@@ -6,7 +6,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end
def destroy
- todo.done
+ TodoService.new.mark_todos_as_done([todo], current_user)
todo_notice = 'Todo was successfully marked as done.'
@@ -14,20 +14,20 @@ class Dashboard::TodosController < Dashboard::ApplicationController
format.html { redirect_to dashboard_todos_path, notice: todo_notice }
format.js { head :ok }
format.json do
- render json: { count: @todos.size, done_count: current_user.todos.done.count }
+ render json: { count: @todos.size, done_count: current_user.todos_done_count }
end
end
end
def destroy_all
- @todos.each(&:done)
+ TodoService.new.mark_todos_as_done(@todos, current_user)
respond_to do |format|
format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' }
format.js { head :ok }
format.json do
find_todos
- render json: { count: @todos.size, done_count: current_user.todos.done.count }
+ render json: { count: @todos.size, done_count: current_user.todos_done_count }
end
end
end