blob: ae79645a96aab708bcae84d9494e531452c4f5ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
module MergeRequests
class AddSpentTimeService < UpdateService
def execute(merge_request)
old_associations = { total_time_spent: merge_request.total_time_spent }
merge_request.spend_time(params[:spend_time])
merge_request_saved = merge_request.with_transaction_returning_status do
merge_request.save
end
if merge_request_saved
create_system_notes(merge_request)
# track usage
track_time_spend_edits(merge_request, old_associations[:total_time_spent])
execute_hooks(merge_request, 'update', old_associations: old_associations)
end
merge_request
end
private
def track_time_spend_edits(merge_request, old_total_time_spent)
if old_total_time_spent != merge_request.total_time_spent
merge_request_activity_counter.track_time_spent_changed_action(user: current_user)
end
end
end
end
|