<commit_before>class Ttc::Train::SchedulesController < ApplicationController
  def show
    render json: as_json
  rescue HttpStatusError => exception
    render status: exception.code, json: { error: exception.message, backtrace: exception.backtrace }
  rescue => exception
    render status: 500, json: { error: exception.message, backtrace: exception.backtrace }
  end

  private

  def nearest_stations
    Ttc::Train::Station.new(latitude, longitude).nearest_stations
  end

  def as_json(_ = nil)
    {
      longitude: longitude,
      latitude: latitude,
      lines: lines
    }
  end

  def lines
    nearest_stations.map do |(line, station)|
      {
        id: line[:id],
        name: line[:name],
        stations: [{
          id: station[:id],
          name: station[:name],
          longitude: station[:longitude],
          latitude: station[:latitude],
          directions: Array(events(line[:id], station[:id]))
        }],
      }
    end
  end

  def events(line_id, station_id)
    Ttc::Train::Client.new(line_id, station_id).events
  end

  def longitude
    if params[:longitude].nil?
      raise HttpStatusError.new(:bad_request, 'missing query parameter longitude')
    end

    params[:longitude]
  end

  def latitude
    if params[:latitude].nil?
      raise HttpStatusError.new(:bad_request, 'missing query parameter latitude')
    end

    params[:latitude]
  end
end<commit_msg>Convert lat and longitude to float<commit_after>class Ttc::Train::SchedulesController < ApplicationController
  def show
    render json: as_json
  rescue HttpStatusError => exception
    render status: exception.code, json: { error: exception.message, backtrace: exception.backtrace }
  rescue => exception
    render status: 500, json: { error: exception.message, backtrace: exception.backtrace }
  end

  private

  def nearest_stations
    Ttc::Train::Station.new(latitude, longitude).nearest_stations
  end

  def as_json(_ = nil)
    {
      longitude: longitude,
      latitude: latitude,
      lines: lines
    }
  end

  def lines
    nearest_stations.map do |(line, station)|
      {
        id: line[:id],
        name: line[:name],
        stations: [{
          id: station[:id],
          name: station[:name],
          longitude: station[:longitude],
          latitude: station[:latitude],
          directions: Array(events(line[:id], station[:id]))
        }],
      }
    end
  end

  def events(line_id, station_id)
    Ttc::Train::Client.new(line_id, station_id).events
  end

  def longitude
    if params[:longitude].nil?
      raise HttpStatusError.new(:bad_request, 'missing query parameter longitude')
    end

    params[:longitude].to_f
  end

  def latitude
    if params[:latitude].nil?
      raise HttpStatusError.new(:bad_request, 'missing query parameter latitude')
    end

    params[:latitude].to_f
  end
end
{'fraction_non_alphanumeric': 0.10633088492479888, 'fraction_numerical': 0.002098635886673662, 'mean_word_length': 2.961218836565097, 'pattern_counts': {'":': 0, '<': 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': '674778', 'n_tokens_mistral': 875, 'n_tokens_neox': 837, 'n_words': 210}