<commit_before>class MiqDialog < ApplicationRecord
  validates_presence_of   :name, :description
  validates_uniqueness_of :name, :scope => :dialog_type, :case_sensitive => false

  DIALOG_DIR = Rails.root.join("product/dialogs/miq_dialogs")

  DIALOG_TYPES = [
    ["VM Provision",                "MiqProvisionWorkflow"],
    ["Configured System Provision", "MiqProvisionConfiguredSystemWorkflow"],
    ["Host Provision",              "MiqHostProvisionWorkflow"],
    ["VM Migrate",                  "VmMigrateWorkflow"],
  ]

  serialize :content

  include ReportableMixin

  def self.seed
    sync_from_dir
  end

  def self.sync_from_dir
    Dir.glob(File.join(DIALOG_DIR, "*.yaml")).each { |f| sync_from_file(f) }
  end

  def self.sync_from_file(filename)
    item = YAML.load_file(filename)

    item[:filename] = filename.sub(DIALOG_DIR.to_path + "/", "")
    item[:file_mtime] = File.mtime(filename).utc
    item[:default] = true

    rec = find_by(:name => item[:name], :filename => item[:filename])

    if rec<commit_msg>Add missing gettext into MiqDialog<commit_after>class MiqDialog < ApplicationRecord
  validates_presence_of   :name, :description
  validates_uniqueness_of :name, :scope => :dialog_type, :case_sensitive => false

  DIALOG_DIR = Rails.root.join("product/dialogs/miq_dialogs")

  DIALOG_TYPES = [
    [_("VM Provision"),                "MiqProvisionWorkflow"],
    [_("Configured System Provision"), "MiqProvisionConfiguredSystemWorkflow"],
    [_("Host Provision"),              "MiqHostProvisionWorkflow"],
    [_("VM Migrate"),                  "VmMigrateWorkflow"],
  ]

  serialize :content

  include ReportableMixin

  def self.seed
    sync_from_dir
  end

  def self.sync_from_dir
    Dir.glob(File.join(DIALOG_DIR, "*.yaml")).each { |f| sync_from_file(f) }
  end

  def self.sync_from_file(filename)
    item = YAML.load_file(filename)

    item[:filename] = filename.sub(DIALOG_DIR.to_path + "/", "")
    item[:file_mtime] = File.mtime(filename).utc
    item[:default] = true

    rec = find_by(:name => item[:name], :filename => item[:filename])

    if rec
{'fraction_non_alphanumeric': 0.12946216087577345, 'fraction_numerical': 0.0, 'mean_word_length': 3.6401766004415013, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5414446', 'n_tokens_mistral': 736, 'n_tokens_neox': 697, 'n_words': 123}