From f2d932268d1b30929e45d7503ef90b325a85e314 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 24 Jun 2019 10:48:50 -0700 Subject: Rename Todos.with_api_entity_associations to with_entity_associations Since this scope is used in both the controller and the API, we rename it to make it clear that it's used for both. --- app/controllers/dashboard/todos_controller.rb | 2 +- app/models/todo.rb | 2 +- lib/api/todos.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 6417cb8e933..27980466a42 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -10,7 +10,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController def index @sort = params[:sort] @todos = @todos.page(params[:page]) - @todos = @todos.with_api_entity_associations + @todos = @todos.with_entity_associations return if redirect_out_of_range(@todos) end diff --git a/app/models/todo.rb b/app/models/todo.rb index f1fc5e599eb..240c91da5b6 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -60,7 +60,7 @@ class Todo < ApplicationRecord scope :for_type, -> (type) { where(target_type: type) } scope :for_target, -> (id) { where(target_id: id) } scope :for_commit, -> (id) { where(commit_id: id) } - scope :with_api_entity_associations, -> { preload(:target, :author, :note, group: :route, project: [:route, { namespace: :route }]) } + scope :with_entity_associations, -> { preload(:target, :author, :note, group: :route, project: [:route, { namespace: :route }]) } scope :joins_issue_and_assignees, -> { left_joins(issue: :assignees) } state_machine :state, initial: :pending do diff --git a/lib/api/todos.rb b/lib/api/todos.rb index d2196f05173..871eaabc887 100644 --- a/lib/api/todos.rb +++ b/lib/api/todos.rb @@ -77,7 +77,7 @@ module API use :pagination end get do - todos = paginate(find_todos.with_api_entity_associations) + todos = paginate(find_todos.with_entity_associations) options = { with: Entities::Todo, current_user: current_user } batch_load_issuable_metadata(todos, options) -- cgit v1.2.3