Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 15:09:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 15:09:18 +0300
commitb7c735c8ac11b8182807070fc6f84f2606e15427 (patch)
treee74b4d25abb8bbf23546f001dd94515e2840a3a3 /app/models
parent221b529789f4090341a825695aeb49b8df6dd11d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/diff_note_position.rb15
-rw-r--r--app/models/note.rb1
-rw-r--r--app/models/performance_monitoring/prometheus_panel.rb2
3 files changed, 15 insertions, 3 deletions
diff --git a/app/models/diff_note_position.rb b/app/models/diff_note_position.rb
index 78e4fbc49eb..716a56c6430 100644
--- a/app/models/diff_note_position.rb
+++ b/app/models/diff_note_position.rb
@@ -28,9 +28,20 @@ class DiffNotePosition < ApplicationRecord
end
def position=(position)
+ assign_attributes(self.class.position_to_attrs(position))
+ end
+
+ def self.create_or_update_for(note, params)
+ attrs = position_to_attrs(params[:position])
+ attrs.merge!(params.slice(:diff_type, :line_code))
+ attrs[:note_id] = note.id
+
+ upsert(attrs, unique_by: [:note_id, :diff_type])
+ end
+
+ def self.position_to_attrs(position)
position_attrs = position.to_h
position_attrs[:diff_content_type] = position_attrs.delete(:position_type)
-
- assign_attributes(position_attrs)
+ position_attrs
end
end
diff --git a/app/models/note.rb b/app/models/note.rb
index 251a75e6025..e6ad7c2227f 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -83,6 +83,7 @@ class Note < ApplicationRecord
has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_one :system_note_metadata
has_one :note_diff_file, inverse_of: :diff_note, foreign_key: :diff_note_id
+ has_many :diff_note_positions
delegate :gfm_reference, :local_reference, to: :noteable
delegate :name, to: :project, prefix: true
diff --git a/app/models/performance_monitoring/prometheus_panel.rb b/app/models/performance_monitoring/prometheus_panel.rb
index 0381c5cff10..3fe029abda0 100644
--- a/app/models/performance_monitoring/prometheus_panel.rb
+++ b/app/models/performance_monitoring/prometheus_panel.rb
@@ -4,7 +4,7 @@ module PerformanceMonitoring
class PrometheusPanel
include ActiveModel::Model
- attr_accessor :type, :title, :y_label, :weight, :metrics, :y_axis
+ attr_accessor :type, :title, :y_label, :weight, :metrics, :y_axis, :max_value
validates :title, presence: true
validates :metrics, presence: true