<commit_before>class Api::V1::StopsController < Api::V1::BaseApiController
  include JsonCollectionPagination
  respond_to :json, :geojson

  before_action :set_stop, only: [:show, :update, :destroy]

  def index
    @stops = Stop.includes(:stop_identifiers).where('') # TODO: check performance against eager_load, joins, etc.
    if params[:identifier].present?
      @stops = @stops.joins(:stop_identifiers).where("stop_identifiers.identifier = ?", params[:identifier])
    end
    if [params[:lat], params[:lon]].map(&:present?).all?
      point = Stop::GEOFACTORY.point(params[:lon], params[:lat])
      r = params[:r] || 100 # meters TODO: move this to a more logical place
      @stops = @stops.where{st_dwithin(geometry, point, r)}.order{st_distance(geometry, point)}
    end
    if params[:bbox].present? && params[:bbox].split(',').length == 4
      bbox_coordinates = params[:bbox].split(',')
      @stops = @stops.where{geometry.op('&&', st_makeenvelope(bbox_coordinates[0], bbox_coordinates[1], bbox_coordinates[2], bbox_coordinates[3], Stop::GEOFACTORY.srid))}
    end

    respond_to do |format|
      format.json do
        render paginated_json_collection(
          @stops,
          Proc.new { |params| api_v1_stops_url(params) },
          params[:offset],
          Stop::PER_PAGE<commit_msg>StopsController `responds_to` is unnecessary<commit_after>class Api::V1::StopsController < Api::V1::BaseApiController
  include JsonCollectionPagination

  before_action :set_stop, only: [:show, :update, :destroy]

  def index
    @stops = Stop.includes(:stop_identifiers).where('') # TODO: check performance against eager_load, joins, etc.
    if params[:identifier].present?
      @stops = @stops.joins(:stop_identifiers).where("stop_identifiers.identifier = ?", params[:identifier])
    end
    if [params[:lat], params[:lon]].map(&:present?).all?
      point = Stop::GEOFACTORY.point(params[:lon], params[:lat])
      r = params[:r] || 100 # meters TODO: move this to a more logical place
      @stops = @stops.where{st_dwithin(geometry, point, r)}.order{st_distance(geometry, point)}
    end
    if params[:bbox].present? && params[:bbox].split(',').length == 4
      bbox_coordinates = params[:bbox].split(',')
      @stops = @stops.where{geometry.op('&&', st_makeenvelope(bbox_coordinates[0], bbox_coordinates[1], bbox_coordinates[2], bbox_coordinates[3], Stop::GEOFACTORY.srid))}
    end

    respond_to do |format|
      format.json do
        render paginated_json_collection(
          @stops,
          Proc.new { |params| api_v1_stops_url(params) },
          params[:offset],
          Stop::PER_PAGE
{'fraction_non_alphanumeric': 0.15118050266565117, 'fraction_numerical': 0.008377760853008377, 'mean_word_length': 4.222664015904573, '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': '5000262', 'n_tokens_mistral': 870, 'n_tokens_neox': 853, 'n_words': 163}