<commit_before>class TreeBuilderOpsVmdb < TreeBuilderOps
  private

  def tree_init_options(_tree_name)
    {
      :open_all => false,
      :leaf     => "VmdbTable",
    }
  end

  def set_locals_for_render
    locals = super
    locals.merge!(
      :id_prefix => "vmdb_",
      :autoload  => true
    )
  end

  # Get root nodes count/array for explorer tree
  def x_get_tree_roots(options)
    objects = rbac_filtered_objects(VmdbDatabase.my_database.evm_tables).sort { |a, b| a.name.downcase <=> b.name.downcase }
    # storing table names and their id in hash so they can be used ot build links on summary screen in top 5 boxes
    @sb[:vmdb_tables] = {}
    objects.each do |o|
      @sb[:vmdb_tables][o.name] = o.id
    end
    options[:count_only] ? objects.length : objects
  end

  # Handle custom tree nodes (object is a Hash)
  def x_get_tree_custom_kids(object, options)
    rec = VmdbTableEvm.find_by_id(from_cid(object[:id].split("|").last.split('-').last))
    indexes = []
    rec.vmdb_indexes.each do |ind|
      indexes.push(ind) if ind.vmdb_table.type == "VmdbTableEvm"
    end
    count_only_or_objects(options[:count_only], indexes, "name")
  end

  def x_get_tree_vmdb_table_kids(object, options)
    if options[:count_only]
      object.vmdb_indexes.count
    else
      # load this node expanded on autoload
      x_tree[:open_nodes].push("xx-#{to_cid(object.id.to_s)}") unless x_tree[:open_nodes].include?("xx-#{to_cid(object.id.to_s)}")
      [
        {
          :id            => "#{to_cid(object.id.to_s)}",
          :text          => "Indexes",
          :image         => "folder",
          :tip           => "Indexes",
          :load_children => true
        }
      ]
    end
  end
end<commit_msg>Fix parse error when getting child nodes in database tree.<commit_after>class TreeBuilderOpsVmdb < TreeBuilderOps
  private

  def tree_init_options(_tree_name)
    {
      :open_all => false,
      :leaf     => "VmdbTable",
    }
  end

  def set_locals_for_render
    locals = super
    locals.merge!(
      :id_prefix => "vmdb_",
      :autoload  => true
    )
  end

  # Get root nodes count/array for explorer tree
  def x_get_tree_roots(options)
    objects = rbac_filtered_objects(VmdbDatabase.my_database.evm_tables).sort { |a, b| a.name.downcase <=> b.name.downcase }
    # storing table names and their id in hash so they can be used ot build links on summary screen in top 5 boxes
    @sb[:vmdb_tables] = {}
    objects.each do |o|
      @sb[:vmdb_tables][o.name] = o.id
    end
    options[:count_only] ? objects.length : objects
  end

  # Handle custom tree nodes (object is a Hash)
  def x_get_tree_custom_kids(object, options)
    rec = VmdbTableEvm.find_by_id(from_cid(object[:id].split("|").last.split('-').last))
    indexes = []
    rec.vmdb_indexes.each do |ind|
      indexes.push(ind) if ind.vmdb_table.type == "VmdbTableEvm"
    end
    count_only_or_objects(options[:count_only], indexes, "name")
  end

  def x_get_tree_vmdb_table_kids(object, options)
    if options[:count_only]
      object.vmdb_indexes.count
    else
      # load this node expanded on autoload
      @tree_state.x_tree(@name)[:open_nodes].push("xx-#{to_cid(object.id.to_s)}") unless @tree_state.x_tree(@name)[:open_nodes].include?("xx-#{to_cid(object.id.to_s)}")
      [
        {
          :id            => "#{to_cid(object.id.to_s)}",
          :text          => "Indexes",
          :image         => "folder",
          :tip           => "Indexes",
          :load_children => true
        }
      ]
    end
  end
end
{'fraction_non_alphanumeric': 0.12341861118920439, 'fraction_numerical': 0.000562271577171774, 'mean_word_length': 2.6794208893485005, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '6632024', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1243, 'n_words': 258}