Class: Notes::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- Notes::CreateService
- Includes:
- IncidentManagement::UsageData
- Defined in:
- app/services/notes/create_service.rb
Direct Known Subclasses
Import::Github::Notes::CreateService, AbuseReport::CreateService
Constant Summary
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 Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods included from IncidentManagement::UsageData
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, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client
Methods inherited from BaseService
#clear_noteable_diffs_cache, #increment_usage_counter
Methods included from Gitlab::InternalEventsTracking
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#execute(skip_capture_diff_note_position: false, skip_merge_status_trigger: false, executing_user: nil, importing: false) ⇒ Object
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/services/notes/create_service.rb', line 7 def execute( skip_capture_diff_note_position: false, skip_merge_status_trigger: false, executing_user: nil, importing: false) Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction( %w[ notes vulnerability_user_mentions ], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/482744' ) do note = build_note(executing_user) # n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/37440 note_valid = Gitlab::GitalyClient.allow_n_plus_1_calls do # We may set errors manually in Notes::BuildService for this reason # we also need to check for already existing errors. note.errors.empty? && note.valid? end return note unless note_valid # rubocop:disable Cop/AvoidReturnFromBlocks -- Temp for decomp exemption # We execute commands (extracted from `params[:note]`) on the noteable # **before** we save the note because if the note consists of commands # only, there is no need be create a note! execute_quick_actions(note) do |only_commands| note.check_for_spam(action: :create, user: current_user) if check_for_spam?(only_commands) after_commit(note) unless importing note_saved = note.with_transaction_returning_status do break false if only_commands note.save.tap do update_discussions(note) end end if note_saved when_saved( note, skip_capture_diff_note_position: skip_capture_diff_note_position, skip_merge_status_trigger: skip_merge_status_trigger ) end end note end end |