<commit_before>class Demo::Application
  route "search" do |r|
    r.get do
      page = (r.params["page"] || 1).to_i
      per_page = (r.params["per_page"] || 20).to_i

      # sleep 1

      if r.params["q"] === "noresult"
        response = {
          results: [],
          pagination: {}
        }
      else
        results = (1..per_page).map {|i|
          id = i + ((page - 1) * per_page)
          {
            id: id,
            label: "Option #{id} for #{r.params["q"]}"
          }
        }

        response = {
          results: results,
          pagination: {
            page: page,
            per_page: per_page,
            total_pages: 10,
            total_results: 195,
          }
        }
      end
      response
    end
  end
end<commit_msg>Complete search method so it responds to `ids` for existing values.<commit_after>class Demo::Application
  route "search" do |r|
    r.get do
      page = (r.params["page"] || 1).to_i
      per_page = (r.params["per_page"] || 20).to_i

      # Return "real" data for existing values
      range = if r.params["ids"]
        r.params["ids"].split(",").map(&:to_i)
      else
        (1..per_page)
      end

      # Fake a no result if "noresult" is passed
      if r.params["q"] === "noresult"
        response = {
          results: [],
          pagination: {}
        }
      else
        results = range.map {|i|
          id = i + ((page - 1) * per_page)
          {
            id: id,
            label: "Option #{id} for #{r.params["q"] || 'no-query'}"
          }
        }

        response = {
          results: results,
          pagination: {
            page: page,
            per_page: per_page,
            total_pages: 10,
            total_results: 195,
          }
        }
      end
      response
    end
  end
end
{'fraction_non_alphanumeric': 0.13513513513513514, 'fraction_numerical': 0.011583011583011582, 'mean_word_length': 1.349740932642487, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5912607', 'n_tokens_mistral': 589, 'n_tokens_neox': 566, 'n_words': 139}