<commit_before>module ManagerRefresh::SaveCollection
  module Helper
    def save_dto_inventory(dto_collection)
      save_dto_inventory_multi(dto_collection.parent.send(dto_collection.association),
                               dto_collection,
                               :use_association,
                               dto_collection.manager_ref)
      store_ids_for_new_dto_records(dto_collection.parent.send(dto_collection.association),
                                    dto_collection)
      dto_collection.saved = true
    end

    def log_format_deletes(deletes)
      ret = deletes.collect do |d|
        s = "id: [#{d.id}]"

        [:name, :product_name, :device_name].each do |k|
          next unless d.respond_to?(k)
          v = d.send(k)
          next if v.nil?
          s << " #{k}: [#{v}]"
          break
        end

        s
      end

      ret.join(", ")
    end
  end
end<commit_msg>DTO batch save based on settings<commit_after>module ManagerRefresh::SaveCollection
  module Helper
    def save_dto_inventory(ems, dto_collection)
      dto_batch_saving = Settings.ems_refresh[ems.class.ems_type].try(:[], :dto_batch_saving)
      if dto_batch_saving
        save_dto_inventory_multi_batch(dto_collection.parent.send(dto_collection.association),
                                       dto_collection,
                                       :use_association,
                                       dto_collection.manager_ref)
      else
        save_dto_inventory_multi(dto_collection.parent.send(dto_collection.association),
                                 dto_collection,
                                 :use_association,
                                 dto_collection.manager_ref)
      end
      store_ids_for_new_dto_records(dto_collection.parent.send(dto_collection.association),
                                    dto_collection)
      dto_collection.saved = true
    end

    def log_format_deletes(deletes)
      ret = deletes.collect do |d|
        s = "id: [#{d.id}]"

        [:name, :product_name, :device_name].each do |k|
          next unless d.respond_to?(k)
          v = d.send(k)
          next if v.nil?
          s << " #{k}: [#{v}]"
          break
        end

        s
      end

      ret.join(", ")
    end
  end
end
{'fraction_non_alphanumeric': 0.08548882069267864, 'fraction_numerical': 0.0, 'mean_word_length': 1.6412037037037037, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1557773', 'n_tokens_mistral': 689, 'n_tokens_neox': 672, 'n_words': 112}