Class: MergeRequest::ApprovalMetrics
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MergeRequest::ApprovalMetrics
- Defined in:
- app/models/merge_request/approval_metrics.rb
Overview
rubocop:disable Style/ClassAndModuleChildren, Gitlab/BoundedContexts – Same as the rest of the models
Constant Summary
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary collapse
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.refresh_last_approved_at(merge_request:, last_approved_at:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/merge_request/approval_metrics.rb', line 9 def self.refresh_last_approved_at(merge_request:, last_approved_at:) attributes = { merge_request_id: merge_request.id, target_project_id: merge_request.target_project_id, last_approved_at: last_approved_at } upsert( attributes, unique_by: :merge_request_id, on_duplicate: Arel.sql(<<~SQL.squish) last_approved_at = GREATEST(excluded.last_approved_at, merge_request_approval_metrics.last_approved_at) SQL ) end |