diff options
Diffstat (limited to 'app/models/alert_management')
-rw-r--r-- | app/models/alert_management/alert.rb | 5 | ||||
-rw-r--r-- | app/models/alert_management/metric_image.rb | 25 |
2 files changed, 30 insertions, 0 deletions
diff --git a/app/models/alert_management/alert.rb b/app/models/alert_management/alert.rb index a53fa39c58f..1ec3cb62c76 100644 --- a/app/models/alert_management/alert.rb +++ b/app/models/alert_management/alert.rb @@ -27,6 +27,7 @@ module AlertManagement has_many :notes, as: :noteable, inverse_of: :noteable, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :ordered_notes, -> { fresh }, as: :noteable, class_name: 'Note' has_many :user_mentions, class_name: 'AlertManagement::AlertUserMention', foreign_key: :alert_management_alert_id + has_many :metric_images, class_name: '::AlertManagement::MetricImage' has_internal_id :iid, scope: :project @@ -142,6 +143,10 @@ module AlertManagement reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE end + def metric_images_available? + ::AlertManagement::MetricImage.available_for?(project) + end + def prometheus? monitoring_tool == Gitlab::AlertManagement::Payload::MONITORING_TOOLS[:prometheus] end diff --git a/app/models/alert_management/metric_image.rb b/app/models/alert_management/metric_image.rb new file mode 100644 index 00000000000..8175a31be7a --- /dev/null +++ b/app/models/alert_management/metric_image.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module AlertManagement + class MetricImage < ApplicationRecord + include MetricImageUploading + self.table_name = 'alert_management_alert_metric_images' + + belongs_to :alert, class_name: 'AlertManagement::Alert', foreign_key: 'alert_id', inverse_of: :metric_images + + def self.available_for?(project) + true + end + + private + + def local_path + Gitlab::Routing.url_helpers.alert_metric_image_upload_path( + filename: file.filename, + id: file.upload.model_id, + model: model_name.param_key, + mounted_as: 'file' + ) + end + end +end |