<commit_before>class Api::V2::RoomsController < Api::V2::BaseController
  def index
    building = Building.for_institution(params[:inst_code]).find_by code: params[:building_code]
    
    respond_with padded_response building.rooms
  end

  def show
    building = Building.for_institution(params[:inst_code]).find_by code: params[:building_code]
    respond_with padded_response Room.find_by("building_id = ? AND code = ? ", building.id, params[:room_code])
  end

  def suggest_details
    building = Building.for_institution(params[:inst_code]).find_by code: params[:building_code]

    room = Room.find_by("building_id = ? AND code = ? ", building.id, params[:room_code])

    suggestion = RoomDetailsSuggestion.new({
         longitude: params[:longitude],
         latitude: params[:latitude],
         room: room,
         latitude: params[:latitude],
     })

    # Crummy validation. TODO(TobiasWooldridge): Fix this.
    if not Float(params[:longitude]) or not Float(params[:longitude])
      raise "Invalid longitude/latitude"
    end

    suggestion.save

    respond_with padded_response suggestion
  end
end<commit_msg>Fixes room details suggestion page POST JSON error<commit_after>class Api::V2::RoomsController < Api::V2::BaseController
  def index
    building = Building.for_institution(params[:inst_code]).find_by code: params[:building_code]
    
    respond_with padded_response building.rooms
  end

  def show
    building = Building.for_institution(params[:inst_code]).find_by code: params[:building_code]
    respond_with padded_response Room.find_by("building_id = ? AND code = ? ", building.id, params[:room_code])
  end

  def suggest_details
    building = Building.for_institution(params[:inst_code]).find_by code: params[:building_code]

    room = Room.find_by("building_id = ? AND code = ? ", building.id, params[:room_code])

    suggestion = RoomDetailsSuggestion.new({
         longitude: params[:longitude],
         latitude: params[:latitude],
         room: room,
         latitude: params[:latitude],
     })

    # Crummy validation. TODO(TobiasWooldridge): Fix this.
    if not Float(params[:longitude]) or not Float(params[:latitude])
      raise "Invalid longitude/latitude"
    end

    suggestion.save

    render json: (padded_response suggestion)
  end
end
{'fraction_non_alphanumeric': 0.10788561525129983, 'fraction_numerical': 0.0017331022530329288, 'mean_word_length': 4.097130242825607, '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': '3301421', 'n_tokens_mistral': 692, 'n_tokens_neox': 682, 'n_words': 147}