BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1554786c
Commit
1554786c
authored
Oct 13, 2015
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eager load various issue/note associations
This ensures we don't end up running N+1 queries for the objects in the affected collections.
parent
ff8f7fb0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
3 deletions
+9
-3
issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
issuable.rb
app/models/concerns/issuable.rb
+6
-1
group.rb
app/models/group.rb
+1
-1
note.rb
app/models/note.rb
+1
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
1554786c
...
...
@@ -57,7 +57,7 @@ class Projects::IssuesController < Projects::ApplicationController
def
show
@participants
=
@issue
.
participants
(
current_user
)
@note
=
@project
.
notes
.
new
(
noteable:
@issue
)
@notes
=
@issue
.
notes
.
inc_a
uthor
.
fresh
@notes
=
@issue
.
notes
.
inc_a
ssociations
.
fresh
@noteable
=
@issue
respond_with
(
@issue
)
...
...
app/models/concerns/issuable.rb
View file @
1554786c
...
...
@@ -47,7 +47,8 @@ module Issuable
prefix:
true
attr_mentionable
:title
,
:description
participant
:author
,
:assignee
,
:notes
,
:mentioned_users
participant
:author
,
:assignee
,
:notes_with_associations
,
:mentioned_users
end
module
ClassMethods
...
...
@@ -176,6 +177,10 @@ module Issuable
self
.
class
.
to_s
.
underscore
end
def
notes_with_associations
notes
.
includes
(
:author
,
:project
)
end
private
def
filter_superceded_votes
(
votes
,
notes
)
...
...
app/models/group.rb
View file @
1554786c
...
...
@@ -64,7 +64,7 @@ class Group < Namespace
end
def
owners
@owners
||=
group_members
.
owners
.
map
(
&
:user
)
@owners
||=
group_members
.
owners
.
includes
(
:user
).
map
(
&
:user
)
end
def
add_users
(
user_ids
,
access_level
,
current_user
=
nil
)
...
...
app/models/note.rb
View file @
1554786c
...
...
@@ -59,6 +59,7 @@ class Note < ActiveRecord::Base
scope
:fresh
,
->
{
order
(
created_at: :asc
,
id: :asc
)
}
scope
:inc_author_project
,
->
{
includes
(
:project
,
:author
)
}
scope
:inc_author
,
->
{
includes
(
:author
)
}
scope
:inc_associations
,
->
{
includes
(
:author
,
:noteable
,
:updated_by
)
}
serialize
:st_diff
before_create
:set_diff
,
if:
->
(
n
)
{
n
.
line_code
.
present?
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment