Commit 44945594 authored by micael.bergeron's avatar micael.bergeron

add association preloading for issue boards

parent 61b596a6
......@@ -11,9 +11,15 @@ module Boards
issues = Boards::Issues::ListService.new(board_parent, current_user, filter_params).execute
issues = issues.page(params[:page]).per(params[:per] || 20)
make_sure_position_is_set(issues)
issues = issues.preload(:project,
:labels,
:milestone,
:assignees,
:notes => [:award_emoji, :author]
)
render json: {
issues: serialize_as_json(issues.preload(:project)),
issues: serialize_as_json(issues),
size: issues.total_count
}
end
......@@ -76,14 +82,13 @@ module Boards
def serialize_as_json(resource)
resource.as_json(
labels: true,
only: [:id, :iid, :project_id, :title, :confidential, :due_date, :relative_position],
labels: true,
include: {
project: { only: [:id, :path] },
assignees: { only: [:id, :name, :username], methods: [:avatar_url] },
milestone: { only: [:id, :title] }
},
user: current_user
}
)
end
end
......
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