Commit f2d93226 authored by Stan Hu's avatar Stan Hu

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.
parent 211a0047
...@@ -10,7 +10,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController ...@@ -10,7 +10,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
def index def index
@sort = params[:sort] @sort = params[:sort]
@todos = @todos.page(params[:page]) @todos = @todos.page(params[:page])
@todos = @todos.with_api_entity_associations @todos = @todos.with_entity_associations
return if redirect_out_of_range(@todos) return if redirect_out_of_range(@todos)
end end
......
...@@ -60,7 +60,7 @@ class Todo < ApplicationRecord ...@@ -60,7 +60,7 @@ class Todo < ApplicationRecord
scope :for_type, -> (type) { where(target_type: type) } scope :for_type, -> (type) { where(target_type: type) }
scope :for_target, -> (id) { where(target_id: id) } scope :for_target, -> (id) { where(target_id: id) }
scope :for_commit, -> (id) { where(commit_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) } scope :joins_issue_and_assignees, -> { left_joins(issue: :assignees) }
state_machine :state, initial: :pending do state_machine :state, initial: :pending do
......
...@@ -77,7 +77,7 @@ module API ...@@ -77,7 +77,7 @@ module API
use :pagination use :pagination
end end
get do 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 } options = { with: Entities::Todo, current_user: current_user }
batch_load_issuable_metadata(todos, options) batch_load_issuable_metadata(todos, options)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment