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
0140e7aa
Commit
0140e7aa
authored
Nov 03, 2016
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system note when time spent for Issue/MergeRequest has changed.
parent
ac0358b5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
24 deletions
+47
-24
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+17
-2
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+0
-4
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+6
-14
app/services/system_note_service.rb
app/services/system_note_service.rb
+24
-4
No files found.
app/services/issuable_base_service.rb
View file @
0140e7aa
...
...
@@ -41,6 +41,11 @@ class IssuableBaseService < BaseService
issuable
,
issuable
.
project
,
current_user
,
issuable
.
time_estimate
)
end
def
create_time_spent_note
(
issuable
,
time_spent
)
SystemNoteService
.
change_time_spent
(
issuable
,
issuable
.
project
,
current_user
,
time_spent
)
end
def
filter_params
(
issuable_ability_name
=
:issue
)
filter_assignee
filter_milestone
...
...
@@ -235,13 +240,15 @@ class IssuableBaseService < BaseService
end
def
change_spent_time
(
issuable
)
time_spent
=
params
.
delete
(
:time_spent
)
if
time_spent
issuable
.
timelogs
.
new
(
time_spent:
time_spent
)
end
end
def
time_spent
@time_spent
||=
params
.
delete
(
:time_spent
)
end
def
has_changes?
(
issuable
,
old_labels:
[])
valid_attrs
=
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:target_branch
]
...
...
@@ -263,6 +270,14 @@ class IssuableBaseService < BaseService
create_task_status_note
(
issuable
)
end
if
issuable
.
previous_changes
.
include?
(
'time_estimate'
)
create_time_estimate_note
(
issuable
)
end
if
time_spent
create_time_spent_note
(
issuable
,
time_spent
)
end
create_labels_note
(
issuable
,
old_labels
)
if
issuable
.
labels
!=
old_labels
end
end
app/services/issues/update_service.rb
View file @
0140e7aa
...
...
@@ -28,10 +28,6 @@ module Issues
create_confidentiality_note
(
issue
)
end
if
issue
.
previous_changes
.
include?
(
'time_estimate'
)
create_time_estimate_note
(
issue
)
end
added_labels
=
issue
.
labels
-
old_labels
if
added_labels
.
present?
notification_service
.
relabeled_issue
(
issue
,
added_labels
,
current_user
)
...
...
app/services/slash_commands/interpret_service.rb
View file @
0140e7aa
...
...
@@ -254,11 +254,7 @@ module SlashCommands
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
command
:estimate
do
|
raw_duration
|
begin
@updates
[
:time_estimate
]
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
rescue
ChronicDuration
::
DurationParseError
# do nothing
end
@updates
[
:time_estimate
]
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
end
desc
'Enter current spent time'
...
...
@@ -268,15 +264,11 @@ module SlashCommands
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
command
:spend
do
|
raw_duration
|
begin
reduce_time
=
raw_duration
.
gsub!
(
/\A-/
,
''
)
time_spent
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
time_spent
=
time_spent
*
-
1
if
reduce_time
@updates
[
:time_spent
]
=
time_spent
rescue
ChronicDuration
::
DurationParseError
# do nothing
end
reduce_time
=
raw_duration
.
gsub!
(
/\A-/
,
''
)
time_spent
=
ChronicDuration
.
parse
(
raw_duration
,
default_unit:
'hours'
)
time_spent
=
time_spent
*
-
1
if
reduce_time
@updates
[
:time_spent
]
=
time_spent
end
def
find_label_ids
(
labels_param
)
...
...
app/services/system_note_service.rb
View file @
0140e7aa
...
...
@@ -113,10 +113,10 @@ module SystemNoteService
# Called when the estimated time of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
#
milestone - Milestone being assigned, or nil
# noteable
- Noteable object
# project
- Project owning noteable
# author
- User performing the change
#
time_estimate - Estimated time
#
# Example Note text:
#
...
...
@@ -131,6 +131,26 @@ module SystemNoteService
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
# Called when the spent time of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
# time_spent - Spent time
#
# Example Note text:
#
# "Added 2h 30m of time spent on this issue"
#
# Returns the created Note object
def
change_time_spent
(
noteable
,
project
,
author
,
time_spent
)
parsed_time
=
ChronicDuration
.
output
(
time_spent
,
format: :short
)
body
=
"Added
#{
parsed_time
}
of time spent on this
#{
noteable
.
to_ability_name
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
# Called when the status of a Noteable is changed
#
# noteable - Noteable object
...
...
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