Commit df8d472a authored by Mark Chao's avatar Mark Chao

Only update when fields actually changed.

parent 23fee68b
module Epics
class UpdateService < Epics::BaseService
EPIC_DATE_FIELDS = %I[
start_date_fixed
start_date_is_fixed
due_date_fixed
due_date_is_fixed
].freeze
def execute(epic)
# start_date and end_date columns are no longer writable by users because those
# are composite fields managed by the system.
......@@ -7,9 +14,7 @@ module Epics
update(epic)
if (params.keys.map(&:to_sym) & [:start_date_fixed, :start_date_is_fixed, :due_date_fixed, :due_date_is_fixed]).present?
epic.update_start_and_due_dates
end
epic.update_start_and_due_dates if have_epic_dates_changed?(epic)
epic
end
......@@ -25,5 +30,11 @@ module Epics
todo_service.update_epic(epic, current_user, old_mentioned_users)
end
private
def have_epic_dates_changed?(epic)
(epic.previous_changes.keys.map(&:to_sym) & EPIC_DATE_FIELDS).present?
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment