<commit_before>class Rack::Attack
  # Rate limits for the API
  throttle('api', limit: 150, period: 5.minutes) do |req|
    req.ip if req.path.match(/\A\/api\//)
  end

  self.throttled_response = lambda do |env|
    now        = Time.now.utc
    match_data = env['rack.attack.match_data']

    headers = {
      'X-RateLimit-Limit'     => match_data[:limit].to_s,
      'X-RateLimit-Remaining' => '0',
      'X-RateLimit-Reset'     => (now + (match_data[:period] - now.to_i % match_data[:period])).to_s
    }

    [429, headers, [{ error: 'Throttled' }.to_json]]
  end
end
<commit_msg>Fix reset date format when rate limited<commit_after>class Rack::Attack
  # Rate limits for the API
  throttle('api', limit: 150, period: 5.minutes) do |req|
    req.ip if req.path.match(/\A\/api\//)
  end

  self.throttled_response = lambda do |env|
    now        = Time.now.utc
    match_data = env['rack.attack.match_data']

    headers = {
      'X-RateLimit-Limit'     => match_data[:limit].to_s,
      'X-RateLimit-Remaining' => '0',
      'X-RateLimit-Reset'     => (now + (match_data[:period] - now.to_i % match_data[:period])).iso8601(6)
    }

    [429, headers, [{ error: 'Throttled' }.to_json]]
  end
end

{'fraction_non_alphanumeric': 0.16611295681063123, 'fraction_numerical': 0.01744186046511628, 'mean_word_length': 2.8253968253968256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '345440', 'n_tokens_mistral': 474, 'n_tokens_neox': 449, 'n_words': 92}