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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
905fdfba
Commit
905fdfba
authored
Feb 17, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add merge request count to each issue on issues list
parent
f02210ca
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
10 deletions
+42
-10
app/assets/images/icon-merge-request-unmerged.svg
app/assets/images/icon-merge-request-unmerged.svg
+1
-0
app/assets/stylesheets/pages/issues.scss
app/assets/stylesheets/pages/issues.scss
+5
-0
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+14
-6
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+2
-2
app/models/merge_requests_closing_issues.rb
app/models/merge_requests_closing_issues.rb
+8
-0
app/views/shared/_issuable_meta_data.html.haml
app/views/shared/_issuable_meta_data.html.haml
+6
-0
changelogs/unreleased/add_mr_info_to_issues_list.yml
changelogs/unreleased/add_mr_info_to_issues_list.yml
+4
-0
No files found.
app/assets/images/icon-merge-request-unmerged.svg
0 → 100644
View file @
905fdfba
<svg
width=
"12"
height=
"15"
viewBox=
"0 0 12 15"
xmlns=
"http://www.w3.org/2000/svg"
><path
d=
"M10.267 11.028V5.167c-.028-.728-.318-1.372-.878-1.923-.56-.55-1.194-.85-1.922-.877h-.934V.5l-2.8 2.8 2.8 2.8V4.233h.934a.976.976 0 0 1 .644.29.88.88 0 0 1 .289.644v5.861a1.86 1.86 0 0 0 .933 3.472 1.86 1.86 0 0 0 .934-3.472zM3.733 3.3a1.86 1.86 0 0 0-1.866-1.867 1.86 1.86 0 0 0-.934 3.472v6.123a1.86 1.86 0 0 0 .933 3.472 1.86 1.86 0 0 0 .934-3.472V4.905c.55-.317.933-.914.933-1.605z"
fill-rule=
"nonzero"
/></svg>
app/assets/stylesheets/pages/issues.scss
View file @
905fdfba
...
...
@@ -10,6 +10,11 @@
.issue-labels
{
display
:
inline-block
;
}
.icon-merge-request-unmerged
{
height
:
13px
;
margin-bottom
:
3px
;
}
}
}
...
...
app/controllers/concerns/issuable_collections.rb
View file @
905fdfba
...
...
@@ -9,24 +9,32 @@ module IssuableCollections
private
def
issuable_meta_data
(
issuable_collection
)
def
issuable_meta_data
(
issuable_collection
,
collection_type
)
# map has to be used here since using pluck or select will
# throw an error when ordering issuables by priority which inserts
# a new order into the collection.
# We cannot use reorder to not mess up the paginated collection.
issuable_ids
=
issuable_collection
.
map
(
&
:id
)
issuable_note_count
=
Note
.
count_for_collection
(
issuable_ids
,
@collection_type
)
issuable_ids
=
issuable_collection
.
map
(
&
:id
)
issuable_note_count
=
Note
.
count_for_collection
(
issuable_ids
,
@collection_type
)
issuable_votes_count
=
AwardEmoji
.
votes_for_collection
(
issuable_ids
,
@collection_type
)
issuable_merge_requests_count
=
if
collection_type
==
'Issue'
MergeRequestsClosingIssues
.
count_for_collection
(
issuable_ids
)
else
[]
end
issuable_ids
.
each_with_object
({})
do
|
id
,
issuable_meta
|
downvotes
=
issuable_votes_count
.
find
{
|
votes
|
votes
.
awardable_id
==
id
&&
votes
.
downvote?
}
upvotes
=
issuable_votes_count
.
find
{
|
votes
|
votes
.
awardable_id
==
id
&&
votes
.
upvote?
}
notes
=
issuable_note_count
.
find
{
|
notes
|
notes
.
noteable_id
==
id
}
upvotes
=
issuable_votes_count
.
find
{
|
votes
|
votes
.
awardable_id
==
id
&&
votes
.
upvote?
}
notes
=
issuable_note_count
.
find
{
|
notes
|
notes
.
noteable_id
==
id
}
merge_requests
=
issuable_merge_requests_count
.
find
{
|
mr
|
mr
.
issue_id
==
id
}
issuable_meta
[
id
]
=
Issuable
::
IssuableMeta
.
new
(
upvotes
.
try
(
:count
).
to_i
,
downvotes
.
try
(
:count
).
to_i
,
notes
.
try
(
:count
).
to_i
notes
.
try
(
:count
).
to_i
,
merge_requests
.
try
(
:count
).
to_i
)
end
end
...
...
app/controllers/projects/issues_controller.rb
View file @
905fdfba
...
...
@@ -26,7 +26,7 @@ class Projects::IssuesController < Projects::ApplicationController
@collection_type
=
"Issue"
@issues
=
issues_collection
@issues
=
@issues
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issues
)
@issuable_meta_data
=
issuable_meta_data
(
@issues
,
@collection_type
)
if
@issues
.
out_of_range?
&&
@issues
.
total_pages
!=
0
return
redirect_to
url_for
(
params
.
merge
(
page:
@issues
.
total_pages
))
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
905fdfba
...
...
@@ -39,7 +39,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@collection_type
=
"MergeRequest"
@merge_requests
=
merge_requests_collection
@merge_requests
=
@merge_requests
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@merge_requests
)
@issuable_meta_data
=
issuable_meta_data
(
@merge_requests
,
@collection_type
)
if
@merge_requests
.
out_of_range?
&&
@merge_requests
.
total_pages
!=
0
return
redirect_to
url_for
(
params
.
merge
(
page:
@merge_requests
.
total_pages
))
...
...
app/models/concerns/issuable.rb
View file @
905fdfba
...
...
@@ -16,9 +16,9 @@ module Issuable
include
TimeTrackable
# This object is used to gather issuable meta data for displaying
# upvotes, downvotes
and note
s count for issues and merge requests
# upvotes, downvotes
, notes and closing merge request
s count for issues and merge requests
# lists avoiding n+1 queries and improving performance.
IssuableMeta
=
Struct
.
new
(
:upvotes
,
:downvotes
,
:notes_count
)
IssuableMeta
=
Struct
.
new
(
:upvotes
,
:downvotes
,
:notes_count
,
:merge_requests_count
)
included
do
cache_markdown_field
:title
,
pipeline: :single_line
...
...
app/models/merge_requests_closing_issues.rb
View file @
905fdfba
...
...
@@ -4,4 +4,12 @@ class MergeRequestsClosingIssues < ActiveRecord::Base
validates
:merge_request_id
,
uniqueness:
{
scope: :issue_id
},
presence:
true
validates
:issue_id
,
presence:
true
class
<<
self
def
count_for_collection
(
ids
)
select
(
'issue_id'
,
'COUNT(*) as count'
).
group
(
:issue_id
).
where
(
issue_id:
ids
)
end
end
end
app/views/shared/_issuable_meta_data.html.haml
View file @
905fdfba
...
...
@@ -2,6 +2,12 @@
-
issue_votes
=
@issuable_meta_data
[
issuable
.
id
]
-
upvotes
,
downvotes
=
issue_votes
.
upvotes
,
issue_votes
.
downvotes
-
issuable_url
=
@collection_type
==
"Issue"
?
issue_path
(
issuable
,
anchor:
'notes'
)
:
merge_request_path
(
issuable
,
anchor:
'notes'
)
-
issuable_mr
=
@issuable_meta_data
[
issuable
.
id
].
merge_requests_count
-
if
issuable_mr
>
0
%li
=
image_tag
(
'icon-merge-request-unmerged'
,
class:
'icon-merge-request-unmerged'
)
=
issuable_mr
-
if
upvotes
>
0
%li
...
...
changelogs/unreleased/add_mr_info_to_issues_list.yml
0 → 100644
View file @
905fdfba
---
title
:
Add merge request count to each issue on issues list
merge_request
:
9252
author
:
blackst0ne
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