Class: Operations::FeatureFlag

Inherits:
ApplicationRecord show all
Includes:
AtomicInternalId, IidRoutes
Defined in:
app/models/operations/feature_flag.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IidRoutes

#to_param

Methods included from AtomicInternalId

#internal_id_read_scope, #internal_id_scope_attrs, #internal_id_scope_usage

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.for_unleash_client(project, environment) ⇒ Object


57
58
59
60
61
62
63
# File 'app/models/operations/feature_flag.rb', line 57

def for_unleash_client(project, environment)
  includes(strategies: [:scopes, :user_list])
    .where(project: project)
    .merge(Operations::FeatureFlags::Scope.on_environment(environment))
    .reorder(:id)
    .references(:operations_scopes)
end

.preload_relationsObject


53
54
55
# File 'app/models/operations/feature_flag.rb', line 53

def preload_relations
  preload(:scopes, strategies: :scopes)
end

Instance Method Details


66
67
68
69
70
71
72
73
74
75
# File 'app/models/operations/feature_flag.rb', line 66

def related_issues(current_user, preload:)
  issues = ::Issue
    .select('issues.*, operations_feature_flags_issues.id AS link_id')
    .joins(:feature_flag_issues)
    .where('operations_feature_flags_issues.feature_flag_id = ?', id)
    .order('operations_feature_flags_issues.id ASC')
    .includes(preload)

  Ability.issues_readable_by_user(issues, current_user)
end