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
a056dfa9
Commit
a056dfa9
authored
Feb 22, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor GlobalMilestone queries.
Make methods return ActiveRecord Relations instead of Arrays.
parent
3231ea10
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
19 additions
and
18 deletions
+19
-18
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-0
app/models/global_milestone.rb
app/models/global_milestone.rb
+13
-13
app/models/merge_request.rb
app/models/merge_request.rb
+0
-1
app/models/project.rb
app/models/project.rb
+1
-0
app/views/dashboard/milestones/_milestone.html.haml
app/views/dashboard/milestones/_milestone.html.haml
+1
-1
app/views/dashboard/milestones/show.html.haml
app/views/dashboard/milestones/show.html.haml
+1
-1
app/views/groups/milestones/_milestone.html.haml
app/views/groups/milestones/_milestone.html.haml
+1
-1
app/views/groups/milestones/show.html.haml
app/views/groups/milestones/show.html.haml
+1
-1
No files found.
app/models/concerns/issuable.rb
View file @
a056dfa9
...
@@ -29,6 +29,7 @@ module Issuable
...
@@ -29,6 +29,7 @@ module Issuable
scope
:assigned
,
->
{
where
(
"assignee_id IS NOT NULL"
)
}
scope
:assigned
,
->
{
where
(
"assignee_id IS NOT NULL"
)
}
scope
:unassigned
,
->
{
where
(
"assignee_id IS NULL"
)
}
scope
:unassigned
,
->
{
where
(
"assignee_id IS NULL"
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_milestones
,
->
(
ids
)
{
where
(
milestone_id:
ids
)
}
scope
:opened
,
->
{
with_state
(
:opened
,
:reopened
)
}
scope
:opened
,
->
{
with_state
(
:opened
,
:reopened
)
}
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
...
...
app/models/global_milestone.rb
View file @
a056dfa9
...
@@ -28,27 +28,27 @@ class GlobalMilestone
...
@@ -28,27 +28,27 @@ class GlobalMilestone
end
end
def
projects
def
projects
milestones
.
map
{
|
milestone
|
milestone
.
project
}
@projects
||=
Project
.
for_milestones
(
milestones
.
map
(
&
:id
))
end
end
def
issue_count
def
issue
s
_count
milestones
.
map
{
|
milestone
|
milestone
.
issues
.
count
}.
sum
issues
.
count
end
end
def
merge_requests_count
def
merge_requests_count
m
ilestones
.
map
{
|
milestone
|
milestone
.
merge_requests
.
count
}.
sum
m
erge_requests
.
count
end
end
def
open_items_count
def
open_items_count
milestones
.
map
{
|
milestone
|
milestone
.
open_items_count
}.
sum
opened_issues
.
count
+
opened_merge_requests
.
count
end
end
def
closed_items_count
def
closed_items_count
milestones
.
map
{
|
milestone
|
milestone
.
closed_items_count
}.
sum
closed_issues
.
count
+
closed_merge_requests
.
count
end
end
def
total_items_count
def
total_items_count
milestones
.
map
{
|
milestone
|
milestone
.
total_items_count
}.
sum
issues_count
+
merge_requests_count
end
end
def
percent_complete
def
percent_complete
...
@@ -76,11 +76,11 @@ class GlobalMilestone
...
@@ -76,11 +76,11 @@ class GlobalMilestone
end
end
def
issues
def
issues
@issues
||=
milestones
.
map
(
&
:issues
).
flatten
.
group_by
(
&
:state
)
@issues
||=
Issue
.
of_milestones
(
milestones
.
map
(
&
:id
)
)
end
end
def
merge_requests
def
merge_requests
@merge_requests
||=
milestones
.
map
(
&
:merge_requests
).
flatten
.
group_by
(
&
:state
)
@merge_requests
||=
MergeRequest
.
of_milestones
(
milestones
.
map
(
&
:id
)
)
end
end
def
participants
def
participants
...
@@ -88,19 +88,19 @@ class GlobalMilestone
...
@@ -88,19 +88,19 @@ class GlobalMilestone
end
end
def
opened_issues
def
opened_issues
issues
.
values_at
(
"opened"
,
"reopened"
).
compact
.
flatten
issues
.
opened
end
end
def
closed_issues
def
closed_issues
issues
[
'closed'
]
issues
.
closed
end
end
def
opened_merge_requests
def
opened_merge_requests
merge_requests
.
values_at
(
"opened"
,
"reopened"
).
compact
.
flatten
merge_requests
.
opened
end
end
def
closed_merge_requests
def
closed_merge_requests
merge_requests
.
values_at
(
"closed"
,
"merged"
,
"locked"
).
compact
.
flatten
merge_requests
.
with_states
(
:closed
,
:merged
,
:locked
)
end
end
def
complete?
def
complete?
...
...
app/models/merge_request.rb
View file @
a056dfa9
...
@@ -139,7 +139,6 @@ class MergeRequest < ActiveRecord::Base
...
@@ -139,7 +139,6 @@ class MergeRequest < ActiveRecord::Base
scope
:of_projects
,
->
(
ids
)
{
where
(
target_project_id:
ids
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
target_project_id:
ids
)
}
scope
:opened
,
->
{
with_states
(
:opened
,
:reopened
)
}
scope
:opened
,
->
{
with_states
(
:opened
,
:reopened
)
}
scope
:merged
,
->
{
with_state
(
:merged
)
}
scope
:merged
,
->
{
with_state
(
:merged
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:closed_and_merged
,
->
{
with_states
(
:closed
,
:merged
)
}
scope
:closed_and_merged
,
->
{
with_states
(
:closed
,
:merged
)
}
scope
:join_project
,
->
{
joins
(
:target_project
)
}
scope
:join_project
,
->
{
joins
(
:target_project
)
}
...
...
app/models/project.rb
View file @
a056dfa9
...
@@ -215,6 +215,7 @@ class Project < ActiveRecord::Base
...
@@ -215,6 +215,7 @@ class Project < ActiveRecord::Base
scope
:public_only
,
->
{
where
(
visibility_level:
Project
::
PUBLIC
)
}
scope
:public_only
,
->
{
where
(
visibility_level:
Project
::
PUBLIC
)
}
scope
:public_and_internal_only
,
->
{
where
(
visibility_level:
Project
.
public_and_internal_levels
)
}
scope
:public_and_internal_only
,
->
{
where
(
visibility_level:
Project
.
public_and_internal_levels
)
}
scope
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
)
}
state_machine
:import_status
,
initial: :none
do
state_machine
:import_status
,
initial: :none
do
event
:import_start
do
event
:import_start
do
...
...
app/views/dashboard/milestones/_milestone.html.haml
View file @
a056dfa9
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
.row
.row
.col-sm-6
.col-sm-6
=
link_to
issues_dashboard_path
(
milestone_title:
milestone
.
title
)
do
=
link_to
issues_dashboard_path
(
milestone_title:
milestone
.
title
)
do
=
pluralize
milestone
.
issue_count
,
'Issue'
=
pluralize
milestone
.
issue
s
_count
,
'Issue'
·
·
=
link_to
merge_requests_dashboard_path
(
milestone_title:
milestone
.
title
)
do
=
link_to
merge_requests_dashboard_path
(
milestone_title:
milestone
.
title
)
do
=
pluralize
milestone
.
merge_requests_count
,
'Merge Request'
=
pluralize
milestone
.
merge_requests_count
,
'Merge Request'
...
...
app/views/dashboard/milestones/show.html.haml
View file @
a056dfa9
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
%li
.active
%li
.active
=
link_to
'#tab-issues'
,
'data-toggle'
=>
'tab'
do
=
link_to
'#tab-issues'
,
'data-toggle'
=>
'tab'
do
Issues
Issues
%span
.badge
=
@milestone
.
issue_count
%span
.badge
=
@milestone
.
issue
s
_count
%li
%li
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
do
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
do
Merge Requests
Merge Requests
...
...
app/views/groups/milestones/_milestone.html.haml
View file @
a056dfa9
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
.row
.row
.col-sm-6
.col-sm-6
=
link_to
issues_group_path
(
@group
,
milestone_title:
milestone
.
title
)
do
=
link_to
issues_group_path
(
@group
,
milestone_title:
milestone
.
title
)
do
=
pluralize
milestone
.
issue_count
,
'Issue'
=
pluralize
milestone
.
issue
s
_count
,
'Issue'
·
·
=
link_to
merge_requests_group_path
(
@group
,
milestone_title:
milestone
.
title
)
do
=
link_to
merge_requests_group_path
(
@group
,
milestone_title:
milestone
.
title
)
do
=
pluralize
milestone
.
merge_requests_count
,
'Merge Request'
=
pluralize
milestone
.
merge_requests_count
,
'Merge Request'
...
...
app/views/groups/milestones/show.html.haml
View file @
a056dfa9
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
%li
.active
%li
.active
=
link_to
'#tab-issues'
,
'data-toggle'
=>
'tab'
do
=
link_to
'#tab-issues'
,
'data-toggle'
=>
'tab'
do
Issues
Issues
%span
.badge
=
@milestone
.
issue_count
%span
.badge
=
@milestone
.
issue
s
_count
%li
%li
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
do
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
do
Merge Requests
Merge Requests
...
...
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