Class: Integrations::SlackWorkspace::ApiScope
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integrations::SlackWorkspace::ApiScope
- Defined in:
- app/models/integrations/slack_workspace/api_scope.rb
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
- .find_or_initialize_by_names(names, organization_id:) ⇒ Object
- .find_or_initialize_by_names_and_organizations(names, organization_ids) ⇒ Object
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
.find_or_initialize_by_names(names, organization_id:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/integrations/slack_workspace/api_scope.rb', line 8 def self.find_or_initialize_by_names(names, organization_id:) found = where(name: names, organization_id: organization_id).to_a missing_names = names - found.pluck(:name) if missing_names.any? upsert_all(missing_names.map { |name| { name: name, organization_id: organization_id } }, on_duplicate: :skip) missing = where(name: missing_names, organization_id: organization_id) found += missing end found end |
.find_or_initialize_by_names_and_organizations(names, organization_ids) ⇒ Object
21 22 23 24 25 |
# File 'app/models/integrations/slack_workspace/api_scope.rb', line 21 def self.find_or_initialize_by_names_and_organizations(names, organization_ids) organization_ids.index_with do |organization_id| find_or_initialize_by_names(names, organization_id: organization_id) end end |