Class: IncidentManagement::TimelineEvents::UpdateService
- Inherits:
-
BaseService
- Object
- BaseService
- IncidentManagement::TimelineEvents::UpdateService
- Defined in:
- app/services/incident_management/timeline_events/update_service.rb
Overview
Constant Summary collapse
- VALIDATION_CONTEXT =
:user_input
Constants included from Gitlab::Utils::UsageData
Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(timeline_event, user, params) ⇒ UpdateService
constructor
A new instance of UpdateService.
Methods inherited from BaseService
#auto_create_predefined_tags, #error, #error_in_save, #error_no_permissions, #success, #track_timeline_event
Methods included from Gitlab::Utils::UsageData
#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #metrics_collection_metadata, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client
Constructor Details
#initialize(timeline_event, user, params) ⇒ UpdateService
Returns a new instance of UpdateService.
13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/incident_management/timeline_events/update_service.rb', line 13 def initialize(timeline_event, user, params) @timeline_event = timeline_event @incident = timeline_event.incident @project = incident.project @user = user @note = params[:note] @occurred_at = params[:occurred_at] @validation_context = VALIDATION_CONTEXT @timeline_event_tags = params[:timeline_event_tag_names] end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/services/incident_management/timeline_events/update_service.rb', line 24 def execute return unless allowed? unless .nil? () # Refetches the tag objects to consider predefined tags as well = timeline_event .project . .by_names() = () return error("#{_("Following tags don't exist")}: #{}") if .any? end begin timeline_event_saved = () rescue ActiveRecord::RecordInvalid error_in_save(timeline_event) end if timeline_event_saved add_system_note(timeline_event) track_timeline_event('incident_management_timeline_event_edited', timeline_event.project) success(timeline_event) else error_in_save(timeline_event) end end |