<commit_before><% cache(test_execution: test_execution) do %>
<div>
  <ul id="error_report_toc" class="nav nav-tabs">
    <li class="active"><a href="#test_summary" data-toggle="tab">Summary</a></li>
    <li class=""><a href="#xml_validation_errors" data-toggle="tab">XML Errors</a></li>
    <li class=""><a href="#xml_validation_warnings" data-toggle="tab">XML Warnings</a></li>
    <li class=""><a href="#xml_validation_cheat_sheet" data-toggle="tab">Record Name Mapping</a></li>

    <% if !test_execution.new_record %>
    <%= link_to "Download", download_test_execution_path(test_execution.id), title: "Download the results of this test execution", class: "cmd pull-right" %>
    <% end %> 
  </ul>
  <div id="test_result_tabs" class="tab-content">
    <div class="tab-pane active" id="test_summary">
      <section>
        <dl class="dl-horizontal">
          <dt><strong>Test Date:</strong></dt> <dd class="strong"><%= test_execution.created_at %></dd>
          <dt><strong>Inspection ID: </strong></dt> <dd><%= test_execution.product_test.product.vendor.name %></dd>
        </dl>
        <dl class="dl-horizontal wide">
          <dt><strong>XML Validation Errors:</strong></dt> <dd class="fail strong"><%= test_execution.count_errors %></dd>
          <dt><strong>XML Validation Warnings:</strong></dt> <dd class="warn strong"><%= test_execution.count_warnings %></dd>
        </dl>
      </section>
      <div>
      </div>      
    </div>
    <%

  error_mapping=[]
  unless test_execution.new_record?
    test_execution.artifact.each_file do |name, data|
      file_errors = test_execution.execution_errors.where({:file_name=> name})
      doc, error_map, error_attributes = match_errors(data, file_errors)
      error_mapping<<{doc: doc, error_map: error_map, error_attributes: error_attributes, file: name, file_errors: file_errors}
   end
  end
 %>
    <div class="tab-pane" id="xml_validation_errors">
      <% #render :partial => 'test_executions/qrda_product_test/errors', :locals => { :errors => test_execution.execution_errors, :inspection => :xml_validation } %> 
      <h4>Errors</h4>
    

      <%  general_errors  = test_execution.execution_errors.where({:file_name=> nil, :msg_type=>:error})
          if general_errors.count > 0 
       %>

            <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: general_errors.group_by(&:file_name), error_map:{}} %>
       <% end %> 
     <ol>    
      <% error_mapping.each do |emap| %>
           <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: emap[:file_errors].by_type(:error).group_by(&:file_name), error_map:emap[:error_map] } %>

       <% end %>

     </ol>
    </div>
    <div class="tab-pane" id="xml_validation_warnings">
     
      <h4>Warnings</h4>
       <ol>

        <%  general_warnings  = test_execution.execution_errors.where({:file_name=> nil, :type=>:msg_warning})
          if general_warnings.count > 0 
       %>
          <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: general_warnings.group_by(&:file_name), error_map:{}} %>
       <% end %>     
      <% error_mapping.each do |emap| %>
          <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: emap[:file_errors].by_type(:warning).group_by(&:file_name), error_map:emap[:error_map] } %>
       <% end %>
     </ol>
    </div>

     <div class="tab-pane" id="xml_validation_cheat_sheet">
       <table>
        <thead> 
          <tr>
          <th >Name </th> <th >Original</th>
        </tr>
        </thead>
        <% test_execution.product_test.records.each do |rec| %>
        <tr > 
          <td style="padding: 5px"><%= rec.last %> ,<%= rec.first %></td> 
          <% if rec.original_record %>
            <td style="padding: 5px"><%= rec.original_record.last %> ,<%= rec.original_record.first %></td>
          <% end %>  
        </tr>

        <% end %>
      </table>
    </div>

  </div><!-- end #test_result_tabs -->

    <div id="xml_frame"> 
    <%= render :partial=>"test_executions/subnav"%>  

    <h3>Vendor Generated XML</h3>
   
   <% error_mapping.each do |emap|

    %>
    <div>
      <div class="expando file_name "><h4> <%= File.basename(emap[:file]) %> </h4> <div class="open" ></div></div>
      <div>
     <%= render :partial=>"test_executions/node" , :locals=>{:doc=>emap[:doc], :error_map=>emap[:error_map], :error_attributes=>emap[:error_attributes], :execution_errors=>emap[:file_errors]}%>
      </div>
   </div>
   <% end %>
  </div>
</div>
<% end %>


<commit_msg>Added an encoding coercion from ASCII-8bit to UTF-8 for filenames<commit_after><% cache(test_execution: test_execution) do %>
<div>
  <ul id="error_report_toc" class="nav nav-tabs">
    <li class="active"><a href="#test_summary" data-toggle="tab">Summary</a></li>
    <li class=""><a href="#xml_validation_errors" data-toggle="tab">XML Errors</a></li>
    <li class=""><a href="#xml_validation_warnings" data-toggle="tab">XML Warnings</a></li>
    <li class=""><a href="#xml_validation_cheat_sheet" data-toggle="tab">Record Name Mapping</a></li>

    <% if !test_execution.new_record %>
    <%= link_to "Download", download_test_execution_path(test_execution.id), title: "Download the results of this test execution", class: "cmd pull-right" %>
    <% end %>
  </ul>
  <div id="test_result_tabs" class="tab-content">
    <div class="tab-pane active" id="test_summary">
      <section>
        <dl class="dl-horizontal">
          <dt><strong>Test Date:</strong></dt> <dd class="strong"><%= test_execution.created_at %></dd>
          <dt><strong>Inspection ID: </strong></dt> <dd><%= test_execution.product_test.product.vendor.name %></dd>
        </dl>
        <dl class="dl-horizontal wide">
          <dt><strong>XML Validation Errors:</strong></dt> <dd class="fail strong"><%= test_execution.count_errors %></dd>
          <dt><strong>XML Validation Warnings:</strong></dt> <dd class="warn strong"><%= test_execution.count_warnings %></dd>
        </dl>
      </section>
      <div>
      </div>
    </div>
    <%

  error_mapping=[]
  unless test_execution.new_record?
    test_execution.artifact.each_file do |name, data|
      file_errors = test_execution.execution_errors.where({:file_name=> name})
      doc, error_map, error_attributes = match_errors(data, file_errors)
      error_mapping<<{doc: doc, error_map: error_map, error_attributes: error_attributes, file: name, file_errors: file_errors}
   end
  end
 %>
    <div class="tab-pane" id="xml_validation_errors">
      <% #render :partial => 'test_executions/qrda_product_test/errors', :locals => { :errors => test_execution.execution_errors, :inspection => :xml_validation } %>
      <h4>Errors</h4>


      <%  general_errors  = test_execution.execution_errors.where({:file_name=> nil, :msg_type=>:error})
          if general_errors.count > 0
       %>

            <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: general_errors.group_by(&:file_name), error_map:{}} %>
       <% end %>
     <ol>
      <% error_mapping.each do |emap| %>
           <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: emap[:file_errors].by_type(:error).group_by(&:file_name), error_map:emap[:error_map] } %>

       <% end %>

     </ol>
    </div>
    <div class="tab-pane" id="xml_validation_warnings">

      <h4>Warnings</h4>
       <ol>

        <%  general_warnings  = test_execution.execution_errors.where({:file_name=> nil, :type=>:msg_warning})
          if general_warnings.count > 0
       %>
          <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: general_warnings.group_by(&:file_name), error_map:{}} %>
       <% end %>
      <% error_mapping.each do |emap| %>
          <%= render :partial=>'test_executions/qrda_product_test/error_list', :locals=>{grouped_errors: emap[:file_errors].by_type(:warning).group_by(&:file_name), error_map:emap[:error_map] } %>
       <% end %>
     </ol>
    </div>

     <div class="tab-pane" id="xml_validation_cheat_sheet">
       <table>
        <thead>
          <tr>
          <th >Name </th> <th >Original</th>
        </tr>
        </thead>
        <% test_execution.product_test.records.each do |rec| %>
        <tr >
          <td style="padding: 5px"><%= rec.last %> ,<%= rec.first %></td>
          <% if rec.original_record %>
            <td style="padding: 5px"><%= rec.original_record.last %> ,<%= rec.original_record.first %></td>
          <% end %>
        </tr>

        <% end %>
      </table>
    </div>

  </div><!-- end #test_result_tabs -->

    <div id="xml_frame">
    <%= render :partial=>"test_executions/subnav"%>

    <h3>Vendor Generated XML</h3>

   <% error_mapping.each do |emap|

    %>
    <div>
      <div class="expando file_name "><h4> <%= File.basename(emap[:file]).force_encoding("UTF-8") %> </h4> <div class="open" ></div></div>
      <div>
     <%= render :partial=>"test_executions/node" , :locals=>{:doc=>emap[:doc], :error_map=>emap[:error_map], :error_attributes=>emap[:error_attributes], :execution_errors=>emap[:file_errors]}%>
      </div>
   </div>
   <% end %>
  </div>
</div>
<% end %>

{'fraction_non_alphanumeric': 0.18330113758317235, 'fraction_numerical': 0.0028976175144880875, 'mean_word_length': 3.4040642722117203, 'pattern_counts': {'":': 0, '<': 281, '<?xml version=': 0, '>': 329, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6199877', 'n_tokens_mistral': 3355, 'n_tokens_neox': 3110, 'n_words': 527}