Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
20b21027
Commit
20b21027
authored
Jun 10, 2014
by
skv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notes count in 1 query for mr and commits
parent
476cd0f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
4 deletions
+15
-4
app/controllers/projects/commits_controller.rb
app/controllers/projects/commits_controller.rb
+2
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+5
-0
app/views/projects/commits/_commit.html.haml
app/views/projects/commits/_commit.html.haml
+8
-4
No files found.
app/controllers/projects/commits_controller.rb
View file @
20b21027
...
@@ -13,6 +13,8 @@ class Projects::CommitsController < Projects::ApplicationController
...
@@ -13,6 +13,8 @@ class Projects::CommitsController < Projects::ApplicationController
@limit
,
@offset
=
(
params
[
:limit
]
||
40
),
(
params
[
:offset
]
||
0
)
@limit
,
@offset
=
(
params
[
:limit
]
||
40
),
(
params
[
:offset
]
||
0
)
@commits
=
@repo
.
commits
(
@ref
,
@path
,
@limit
,
@offset
)
@commits
=
@repo
.
commits
(
@ref
,
@path
,
@limit
,
@offset
)
@note_counts
=
Note
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
html
# index.html.erb
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
20b21027
...
@@ -32,6 +32,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -32,6 +32,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
show
def
show
@note_counts
=
Note
.
where
(
commit_id:
@merge_request
.
commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
diff
{
render
text:
@merge_request
.
to_diff
(
current_user
)
}
format
.
diff
{
render
text:
@merge_request
.
to_diff
(
current_user
)
}
...
@@ -78,6 +80,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -78,6 +80,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@commits
.
map!
{
|
commit
|
Commit
.
new
(
commit
)
}
@commits
.
map!
{
|
commit
|
Commit
.
new
(
commit
)
}
@commit
=
@commits
.
first
@commit
=
@commits
.
first
@note_counts
=
Note
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
@diffs
=
compare_action
.
diffs
@diffs
=
compare_action
.
diffs
@merge_request
.
title
=
@merge_request
.
source_branch
.
titleize
.
humanize
@merge_request
.
title
=
@merge_request
.
source_branch
.
titleize
.
humanize
@target_project
=
@merge_request
.
target_project
@target_project
=
@merge_request
.
target_project
...
...
app/views/projects/commits/_commit.html.haml
View file @
20b21027
...
@@ -9,11 +9,15 @@
...
@@ -9,11 +9,15 @@
=
link_to
"Browse Code »"
,
project_tree_path
(
project
,
commit
),
class:
"pull-right"
=
link_to
"Browse Code »"
,
project_tree_path
(
project
,
commit
),
class:
"pull-right"
.notes_count
.notes_count
-
notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
)
-
if
@note_counts
-
if
notes
.
any?
-
note_count
=
@note_counts
.
fetch
(
commit
.
id
,
0
)
-
else
-
notes
=
project
.
notes
.
for_commit_id
(
commit
.
id
)
-
note_count
=
notes
.
count
-
if
note_count
>
0
%span
.label.label-gray
%span
.label.label-gray
%i
.icon-comment
%i
.icon-comment
=
note_count
=
notes
.
count
-
if
commit
.
description?
-
if
commit
.
description?
.commit-row-description.js-toggle-content
.commit-row-description.js-toggle-content
...
...
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