<commit_before>SearchController < MapController

  def collect_department_data
     geo_json = json_department_search(params[:search])
     render plain: geo_json.to_json
  end


end<commit_msg>Creating department search method<commit_after>SearchController < MapController

  def index
     geo_json = json_department_search(params[:search])
     render plain: geo_json.to_json
  end

  def json_department_search(search)
    @department = Department.where('acronym LIKE ?', "%#{search}%")
    features = []
    @department.each_with_index do |department, index|

      properties = {
        popupContent: "MDS",
        title: department.acronym,
        description: department.title,
        image: 'fa-department'
      }

      geo_data = JSON.parse department.geo_data
      geo_data['features'].each do |feature|
        feature.merge!(properties: properties)
        features.push(feature)
      end

    end
    geo_json = {
     type: "FeatureCollection",
     features: features
    }
end
{'fraction_non_alphanumeric': 0.09290709290709291, 'fraction_numerical': 0.0, 'mean_word_length': 3.2278481012658227, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6977718', 'n_tokens_mistral': 313, 'n_tokens_neox': 287, 'n_words': 60}