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
d789295a
Commit
d789295a
authored
Apr 13, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set closed and reopened issues without closed_at to milestone start date
parent
465b4ec5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
5 deletions
+40
-5
app/models/burndown.rb
app/models/burndown.rb
+10
-5
changelogs/unreleased-ee/issue_2151.yml
changelogs/unreleased-ee/issue_2151.yml
+4
-0
spec/models/burndown_spec.rb
spec/models/burndown_spec.rb
+26
-0
No files found.
app/models/burndown.rb
View file @
d789295a
class
Burndown
attr_accessor
:start_date
,
:due_date
,
:end_date
,
:issues_count
,
:issues_weight
attr_accessor
:start_date
,
:due_date
,
:end_date
,
:issues_count
,
:issues_weight
,
:has_data
def
initialize
(
milestone
)
@milestone
=
milestone
...
...
@@ -7,6 +7,7 @@ class Burndown
@due_date
=
@milestone
.
due_date
@end_date
=
@milestone
.
due_date
@end_date
=
Date
.
today
if
@end_date
.
present?
&&
@end_date
>
Date
.
today
@has_data
=
issues_with_closed_at
.
pluck
(
:closed_at
).
compact
.
any?
@issues_count
,
@issues_weight
=
milestone
.
issues
.
reorder
(
nil
).
pluck
(
'COUNT(*), COALESCE(SUM(weight), 0)'
).
first
end
...
...
@@ -51,7 +52,11 @@ class Burndown
def
closed_and_reopened_issues_by
(
date
)
current_date
=
date
.
to_date
closed
=
issues_with_closed_at
.
select
{
|
issue
|
issue
.
closed_at
.
to_date
==
current_date
}
closed
=
issues_with_closed_at
.
select
do
|
issue
|
(
issue
.
closed_at
&
.
to_date
||
@start_date
)
==
current_date
end
reopened
=
closed
.
select
{
|
issue
|
issue
.
state
==
'reopened'
}
[
closed
,
reopened
]
...
...
@@ -59,8 +64,8 @@ class Burndown
def
issues_with_closed_at
@issues_with_closed_at
||=
@milestone
.
issues
.
select
(
'closed_at, weight, state'
).
where
(
'closed_at IS NOT NULL'
).
order
(
'closed_at ASC'
)
@milestone
.
issues
.
select
(
"closed_at, weight, state"
).
where
(
"state IN ('reopened', 'closed')"
).
order
(
"closed_at ASC"
)
end
end
changelogs/unreleased-ee/issue_2151.yml
0 → 100644
View file @
d789295a
---
title
:
Set closed and reopened issues without closed_at to milestone start date
merge_request
:
author
:
spec/models/burndown_spec.rb
View file @
d789295a
...
...
@@ -57,6 +57,32 @@ describe Burndown, models: true do
expect
(
JSON
.
parse
(
subject
).
last
[
0
]).
to
eq
(
Time
.
now
.
strftime
(
"%Y-%m-%d"
))
end
it
"it sets attribute has_data to true"
do
burndown
=
described_class
.
new
(
milestone
)
expect
(
burndown
.
has_data
).
to
be_truthy
end
context
"when closed and reopened issues does not have closed_at"
do
before
{
milestone
.
issues
.
update_all
(
closed_at:
nil
)
}
it
"it considers closed_at as milestone start date"
do
expect
(
subject
).
to
eq
([
[
"2017-03-01"
,
15
,
30
],
[
"2017-03-02"
,
27
,
54
],
[
"2017-03-03"
,
27
,
54
],
[
"2017-03-04"
,
27
,
54
],
[
"2017-03-05"
,
27
,
54
]
].
to_json
)
end
it
"it sets attribute has_data to false"
do
burndown
=
described_class
.
new
(
milestone
)
expect
(
burndown
.
has_data
).
to
be_falsy
end
end
# Creates, closes and reopens issues only for odd days numbers
def
build_sample
milestone
.
start_date
.
upto
(
milestone
.
due_date
)
do
|
date
|
...
...
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