<commit_before>require "net/http"
require "json"
require "open-uri"
require "httparty"
require "will_paginate/array"

class GuideController < ApplicationController

 def index

 end


 def search
    logger.debug("Querying Muninn...")

     page = params[:page]
     #json_string = '{"query":{"match_all":{}}, "facets": {"tags":{ "terms" : {"field" : "_type"}}},"from":"0","size":"999"}'
		 json_string = MuninnCustomSearchAdapter.create_search_string( params[:q] )

     @query_result = MuninnCustomSearchAdapter.custom_query(json_string, page, 15 )


     @node_types = [ 'term', 'office', 'report'  ]
     @results = {}
     @node_types.each do |type_name|

       @results[type_name] = @query_result.select { |k| "#{k[:type]}" == type_name }
       @results[type_name] = @results[type_name].sort_by { |k| "#{k[:sort_name]}"}
       @results[type_name] = @results[type_name].paginate(:page=> page, :per_page => 15)

     end



     # get a hash of result count by node type
     @results_count = @query_result.select { |k| "#{k[:type]}" =="count"}
     @results_count = @results_count[0][:totalcount]
     @results_hash = {}
     @results_count.each do |hash|
        @results_hash[hash["term"]] = hash["count"]
     end

    render html: "partial_office_search", layout: false
 end

end<commit_msg>modified guide to handle the tabs in loop structure<commit_after>require "net/http"
require "json"
require "open-uri"
require "httparty"
require "will_paginate/array"

class GuideController < ApplicationController

 def index

 end


 def search
    logger.debug("Querying Muninn...")

     page = params[:page]
     #json_string = '{"query":{"match_all":{}}, "facets": {"tags":{ "terms" : {"field" : "_type"}}},"from":"0","size":"999"}'
		 json_string = MuninnCustomSearchAdapter.create_search_string( params[:q] )

     @query_result = MuninnCustomSearchAdapter.custom_query(json_string, page, 15 )


     @node_types = [ 'term', 'office', 'report'  ]
     @results = {}
     @node_types.each do |type_name|

       @results[type_name] = @query_result.select { |k| "#{k[:type]}" == type_name }
       @results[type_name] = @results[type_name].sort_by { |k| "#{k[:sort_name]}"}
       @results[type_name] = @results[type_name].paginate(:page=> page, :per_page => 15)

     end



     # get a hash of result count by node type
     @results_count = @query_result.select { |k| "#{k[:type]}" =="count"}
     @results_count = @results_count[0][:totalcount]
     @results_hash = {}
     @results_count.each do |hash|
        @results_hash[hash["term"]] = hash["count"]
     end

     render html: "partial_search", layout: false
 end

end
{'fraction_non_alphanumeric': 0.16906747536012132, 'fraction_numerical': 0.006823351023502654, 'mean_word_length': 4.017110266159696, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 7, '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': '3085838', 'n_tokens_mistral': 917, 'n_tokens_neox': 858, 'n_words': 185}