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
e53169c9
Commit
e53169c9
authored
May 29, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve N+1 query issue with discussions
parent
1ac12698
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
noteable.rb
app/models/concerns/noteable.rb
+6
-1
discussion.rb
app/models/discussion.rb
+2
-1
dm-discussions-n-plus-1.yml
changelogs/unreleased/dm-discussions-n-plus-1.yml
+4
-0
No files found.
app/models/concerns/noteable.rb
View file @
e53169c9
...
...
@@ -43,7 +43,12 @@ module Noteable
end
def
resolvable_discussions
@resolvable_discussions
||=
discussion_notes
.
resolvable
.
discussions
(
self
)
@resolvable_discussions
||=
if
defined?
(
@discussions
)
@discussions
.
select
(
&
:resolvable?
)
else
discussion_notes
.
resolvable
.
discussions
(
self
)
end
end
def
discussions_resolvable?
...
...
app/models/discussion.rb
View file @
e53169c9
...
...
@@ -21,7 +21,8 @@ class Discussion
end
def
self
.
build_collection
(
notes
,
context_noteable
=
nil
)
notes
.
group_by
{
|
n
|
n
.
discussion_id
(
context_noteable
)
}.
values
.
map
{
|
notes
|
build
(
notes
,
context_noteable
)
}
grouped_notes
=
notes
.
includes
(
:noteable
).
group_by
{
|
n
|
n
.
discussion_id
(
context_noteable
)
}
grouped_notes
.
values
.
map
{
|
notes
|
build
(
notes
,
context_noteable
)
}
end
# Returns an alphanumeric discussion ID based on `build_discussion_id`
...
...
changelogs/unreleased/dm-discussions-n-plus-1.yml
0 → 100644
View file @
e53169c9
---
title
:
Resolve N+1 query issue with discussions
merge_request
:
author
:
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