<commit_before>class Api::V1::ScheduleStopPairsController < Api::V1::BaseApiController
  include Geojson
  include JsonCollectionPagination
  include DownloadableCsv

  def index
    @ssps = ScheduleStopPair.where('')

    # Service on a date
    if params[:date].present?
      @ssps = @ssps.where_service_on_date(params[:date])
    end

    if params[:service_from_date].present?
      @ssps = @ssps.where_service_from_date(params[:service_from_date])
    end
    
    # Service between stops
    if params[:origin_onestop_id].present?
      @ssps = @ssps.where(origin_id: Stop.find_by!(onestop_id: params[:origin_onestop_id]).id)
    end
    if params[:destination_onestop_id].present?
      @ssps = @ssps.where(destination_id: Stop.find_by!(onestop_id: params[:destination_onestop_id]).id)
    end
    
    # Service on a route
    if params[:route_onestop_id].present?
      @ssps = @ssps.where(route_id: Route.find_by!(onestop_id: params[:route_onestop_id]).id)
    end

    # Stops in a bounding box
    if params[:bbox].present?
      @ssps = @ssps.where_origin_bbox(params[:bbox])
    end
    
    # Edges updated since
    if params[:updated_since].present?
      @ssps = @ssps.updated_since(params[:updated_since])
    end

    per_page = params[:per_page].blank? ? ScheduleStopPair::PER_PAGE : params[:per_page].to_i

    respond_to do |format|
      format.json do
        render paginated_json_collection(
          @ssps,
          Proc.new { |params| api_v1_schedule_stop_pairs_url(params) },
          params[:offset],
          per_page,
          params.slice(:service_start_date, :service_end_date)
        )
      end
      format.geojson do
        render json: Geojson.from_entity_collection(@ssps)
      end
      # format.csv do
      #   return_downloadable_csv(@ssps, 'ssps')
      # end
    end

  end

  def frequency
    
  end

end<commit_msg>ScheduleStopPair endpoint should include all query params in next page URL<commit_after>class Api::V1::ScheduleStopPairsController < Api::V1::BaseApiController
  include Geojson
  include JsonCollectionPagination
  include DownloadableCsv

  def index
    @ssps = ScheduleStopPair.where('')

    # Service on a date
    if params[:date].present?
      @ssps = @ssps.where_service_on_date(params[:date])
    end

    if params[:service_from_date].present?
      @ssps = @ssps.where_service_from_date(params[:service_from_date])
    end

    # Service between stops
    if params[:origin_onestop_id].present?
      @ssps = @ssps.where(origin_id: Stop.find_by!(onestop_id: params[:origin_onestop_id]).id)
    end
    if params[:destination_onestop_id].present?
      @ssps = @ssps.where(destination_id: Stop.find_by!(onestop_id: params[:destination_onestop_id]).id)
    end

    # Service on a route
    if params[:route_onestop_id].present?
      @ssps = @ssps.where(route_id: Route.find_by!(onestop_id: params[:route_onestop_id]).id)
    end

    # Stops in a bounding box
    if params[:bbox].present?
      @ssps = @ssps.where_origin_bbox(params[:bbox])
    end

    # Edges updated since
    if params[:updated_since].present?
      @ssps = @ssps.updated_since(params[:updated_since])
    end

    per_page = params[:per_page].blank? ? ScheduleStopPair::PER_PAGE : params[:per_page].to_i

    respond_to do |format|
      format.json do
        render paginated_json_collection(
          @ssps,
          Proc.new { |params| api_v1_schedule_stop_pairs_url(params) },
          params[:offset],
          per_page,
          params.slice(:date, :service_from_date, :origin_onestop_id, :destination_onestop_id, :route_onestop_id, :bbox, :updated_since)
        )
      end
      format.geojson do
        render json: Geojson.from_entity_collection(@ssps)
      end
      # format.csv do
      #   return_downloadable_csv(@ssps, 'ssps')
      # end
    end

  end

  def frequency

  end

end
{'fraction_non_alphanumeric': 0.10550814584949574, 'fraction_numerical': 0.0015515903801396431, 'mean_word_length': 3.241228070175439, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4551772', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1292, 'n_words': 234}