<commit_before>class MiqRegion < ActiveRecord::Base
  has_many :zones,                  :finder_sql => lambda { |_| Zone.in_region(region_number).to_sql }
  has_many :ext_management_systems, :finder_sql => lambda { |_| ExtManagementSystem.in_region(region_number).to_sql }
  has_many :vms_and_templates,      :finder_sql => lambda { |_| VmOrTemplate.in_region(region_number).to_sql }
  has_many :vms,                    :finder_sql => lambda { |_| Vm.in_region(region_number).to_sql }
  has_many :miq_templates,          :finder_sql => lambda { |_| MiqTemplate.in_region(region_number).to_sql }
  has_many :hosts,                  :finder_sql => lambda { |_| Host.in_region(region_number).to_sql }
  has_many :storages,               :finder_sql => lambda { |_| Storage.in_region(region_number).to_sql }
  has_many :policy_events,          :finder_sql => lambda { |_| PolicyEvent.in_region(region_number).to_sql }
  has_many :miq_servers,            :finder_sql => lambda { |_| MiqServer.in_region(region_number).to_sql }
  has_many :active_miq_servers,     :finder_sql => lambda { |_| MiqServer.in_region(region_number).where(:status => ['started', 'starting']).to_sql }, :class_name => "MiqServer"

  has_many :database_backups, :dependent => :destroy, :finder_sql => lambda { |_| DatabaseBackup.in_region(region_number).to_sql }

  has_many :metrics,        :as => :resource # Destroy will be handled by purger
  has_many :metric_rollups, :as => :resource # Destroy will be handled by purger
  has_many :vim_performance_states, :as => :resource # Destroy will be handled by purger

  acts_as_miq_taggable
  include ReportableMixin
  include UuidMixin

  include AggregationMixin
  # Since we've overridden the implementation of methods from AggregationMixin,
  # we must also override the :uses portion of the virtual columns.
  override_aggregation_mixin_virtual_columns_uses(:all_hosts, :hosts)
  override_aggregation_mixin_virtual_columns_uses(:all_vms_and_templates, :vms_and_templates)

  include MiqPolicyMixin
  include Metric::CiMixin

  alias all_vms_and_templates  vms_and_templates
  alias all_vm_or_template_ids vm_or_template_ids
  alias all_vms                vms
  alias all_vm_ids             vm_ids
  alias all_miq_templates      miq_templates
  alias all_miq_template_ids   miq_template_ids
  alias all_hosts              hosts
  alias all_host_ids           host_ids<commit_msg>A region is the database so it's never destroyed.<commit_after>class MiqRegion < ActiveRecord::Base
  has_many :zones,                  :finder_sql => lambda { |_| Zone.in_region(region_number).to_sql }
  has_many :ext_management_systems, :finder_sql => lambda { |_| ExtManagementSystem.in_region(region_number).to_sql }
  has_many :vms_and_templates,      :finder_sql => lambda { |_| VmOrTemplate.in_region(region_number).to_sql }
  has_many :vms,                    :finder_sql => lambda { |_| Vm.in_region(region_number).to_sql }
  has_many :miq_templates,          :finder_sql => lambda { |_| MiqTemplate.in_region(region_number).to_sql }
  has_many :hosts,                  :finder_sql => lambda { |_| Host.in_region(region_number).to_sql }
  has_many :storages,               :finder_sql => lambda { |_| Storage.in_region(region_number).to_sql }
  has_many :policy_events,          :finder_sql => lambda { |_| PolicyEvent.in_region(region_number).to_sql }
  has_many :miq_servers,            :finder_sql => lambda { |_| MiqServer.in_region(region_number).to_sql }
  has_many :active_miq_servers,     :finder_sql => lambda { |_| MiqServer.in_region(region_number).where(:status => ['started', 'starting']).to_sql }, :class_name => "MiqServer"

  has_many :database_backups, :finder_sql => lambda { |_| DatabaseBackup.in_region(region_number).to_sql }

  has_many :metrics,        :as => :resource # Destroy will be handled by purger
  has_many :metric_rollups, :as => :resource # Destroy will be handled by purger
  has_many :vim_performance_states, :as => :resource # Destroy will be handled by purger

  acts_as_miq_taggable
  include ReportableMixin
  include UuidMixin

  include AggregationMixin
  # Since we've overridden the implementation of methods from AggregationMixin,
  # we must also override the :uses portion of the virtual columns.
  override_aggregation_mixin_virtual_columns_uses(:all_hosts, :hosts)
  override_aggregation_mixin_virtual_columns_uses(:all_vms_and_templates, :vms_and_templates)

  include MiqPolicyMixin
  include Metric::CiMixin

  alias all_vms_and_templates  vms_and_templates
  alias all_vm_or_template_ids vm_or_template_ids
  alias all_vms                vms
  alias all_vm_ids             vm_ids
  alias all_miq_templates      miq_templates
  alias all_miq_template_ids   miq_template_ids
  alias all_hosts              hosts
  alias all_host_ids           host_ids
{'fraction_non_alphanumeric': 0.08748960931005818, 'fraction_numerical': 0.0, 'mean_word_length': 4.0609884332281805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6587522', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1555, 'n_words': 311}