diff options
Diffstat (limited to 'app/models/operations')
-rw-r--r-- | app/models/operations/feature_flag.rb | 19 | ||||
-rw-r--r-- | app/models/operations/feature_flags/user_list.rb | 7 |
2 files changed, 24 insertions, 2 deletions
diff --git a/app/models/operations/feature_flag.rb b/app/models/operations/feature_flag.rb index 104338b80d1..442f9d36c43 100644 --- a/app/models/operations/feature_flag.rb +++ b/app/models/operations/feature_flag.rb @@ -2,6 +2,7 @@ module Operations class FeatureFlag < ApplicationRecord + include AfterCommitQueue include AtomicInternalId include IidRoutes include Limitable @@ -12,7 +13,7 @@ module Operations belongs_to :project - has_internal_id :iid, scope: :project, init: ->(s) { s&.project&.operations_feature_flags&.maximum(:iid) } + has_internal_id :iid, scope: :project default_value_for :active, true @@ -77,6 +78,22 @@ module Operations Ability.issues_readable_by_user(issues, current_user) end + def execute_hooks(current_user) + run_after_commit do + feature_flag_data = Gitlab::DataBuilder::FeatureFlag.build(self, current_user) + project.execute_hooks(feature_flag_data, :feature_flag_hooks) + end + end + + def hook_attrs + { + id: id, + name: name, + description: description, + active: active + } + end + private def version_associations diff --git a/app/models/operations/feature_flags/user_list.rb b/app/models/operations/feature_flags/user_list.rb index b9bdcb59d5f..3e492eaa892 100644 --- a/app/models/operations/feature_flags/user_list.rb +++ b/app/models/operations/feature_flags/user_list.rb @@ -5,6 +5,7 @@ module Operations class UserList < ApplicationRecord include AtomicInternalId include IidRoutes + include ::Gitlab::SQL::Pattern self.table_name = 'operations_user_lists' @@ -12,7 +13,7 @@ module Operations has_many :strategy_user_lists has_many :strategies, through: :strategy_user_lists - has_internal_id :iid, scope: :project, init: ->(s) { s&.project&.operations_feature_flags_user_lists&.maximum(:iid) }, presence: true + has_internal_id :iid, scope: :project, presence: true validates :project, presence: true validates :name, @@ -23,6 +24,10 @@ module Operations before_destroy :ensure_no_associated_strategies + scope :for_name_like, -> (query) do + fuzzy_search(query, [:name], use_minimum_char_limit: false) + end + private def ensure_no_associated_strategies |