<commit_before><div id="data" style="display:none">
  <%
     resource_hash = data_search
     common_facet_config = YAML.load(File.read(common_faceted_search_config_path))
     specified_facet_config = YAML.load(File.read(specified_faceted_search_config_path))
     external_faceted_config = YAML.load(File.read(external_faceted_search_config_path))

     #generate tree for HierarchicalFacet
     all_facet_config = common_facet_config
     resource_hash.keys.each do |object_type|
       all_facet_config = all_facet_config.merge(specified_facet_config[object_type] || {})
     end
     exhibit_items = exhibit_trees all_facet_config

     #generate exhibit_items
     resource_hash.each do |key,value|
       objects = value[:items]
       objects.each do |object|
        if object.respond_to?(:is_external_search_result?) && object.is_external_search_result?
           facets_for_object = external_faceted_config[key] || {}
           config = common_facet_config.merge(facets_for_object)
           exhibit_item = exhibit_item_for_external_resource object, config
        else
          facets_for_object = specified_facet_config[key] || {}
          config = common_facet_config.merge(facets_for_object)
          exhibit_item = exhibit_item_for object, config
        end

        exhibit_items << exhibit_item
       end
     end
  %>

  {
  "items": <%= exhibit_items.to_json %>
  }

</div>
<commit_msg>improve speed a bit<commit_after><div id="data" style="display:none">
  <%
     resource_hash = data_search
     common_facet_config = YAML.load(File.read(common_faceted_search_config_path))
     specified_facet_config = YAML.load(File.read(specified_faceted_search_config_path))
     external_faceted_config = YAML.load(File.read(external_faceted_search_config_path))

     #generate tree for HierarchicalFacet
     all_facet_config = common_facet_config
     resource_hash.keys.each do |object_type|
       all_facet_config = all_facet_config.merge(specified_facet_config[object_type] || {})
     end
     exhibit_items = exhibit_trees all_facet_config

     #generate exhibit_items
     resource_hash.each do |key,value|
       objects = value[:items]
       if objects.first.respond_to?(:is_external_search_result?) && objects.first.is_external_search_result?
         facets_for_object = external_faceted_config[key] || {}
         config = common_facet_config.merge(facets_for_object)
       else
         facets_for_object = specified_facet_config[key] || {}
         config = common_facet_config.merge(facets_for_object)
       end

       objects.each do |object|
        if object.respond_to?(:is_external_search_result?) && object.is_external_search_result?
           exhibit_item = exhibit_item_for_external_resource object, config
        else
           exhibit_item = exhibit_item_for object, config
        end

        exhibit_items << exhibit_item
       end
     end
  %>

  {
  "items": <%= exhibit_items.to_json %>
  }

</div>

{'fraction_non_alphanumeric': 0.08434547908232119, 'fraction_numerical': 0.0, 'mean_word_length': 3.5968992248062017, 'pattern_counts': {'":': 2, '<': 15, '<?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': '1208677', 'n_tokens_mistral': 948, 'n_tokens_neox': 936, 'n_words': 136}