<commit_before>class MapController < ApplicationController
  layout false
  def index

  end

  def building
    @building = Building.find(params[:id])

  end

  def data
    @buildings = Building.all
    render json: @buildings

  end

  def routes
      @buildings = Building.all
  end

  def search_building
      @buildings = Building.all
  end

  def collect_building_data
    @buildings = Building.all

    features = []
    @buildings.each_with_index do |building, index|

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

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

    end

     geo_json = {
      type: "FeatureCollection",
      features: features
    }

    render plain: geo_json.to_json
  end

end<commit_msg>Refactoring json conversion method of buildings for search<commit_after>class MapController < ApplicationController
  layout false
  def index

  end

  def building
    @building = Building.find(params[:id])

  end

  def data
    @buildings = Building.all
    render json: @buildings

  end

  def routes
      @buildings = Building.all
  end

  def search_building
      @buildings = Building.all
  end

  def collect_building_data
    @buildings = Building.all
    geo_json = json_building_search(@buildings)
    render plain: geo_json.to_json
  end

  def json_building_search(buildings)

    features = []
    buildings.each_with_index do |building, index|

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

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

    end

     geo_json = {
      type: "FeatureCollection",
      features: features
    }
  end

end
{'fraction_non_alphanumeric': 0.078743961352657, 'fraction_numerical': 0.0, 'mean_word_length': 2.522108843537415, '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': '5205393', 'n_tokens_mistral': 633, 'n_tokens_neox': 594, 'n_words': 151}