<commit_before>class Sidekiq::Grouping::Flusher
  def flush
    batches = Sidekiq::Grouping::Batch.all.map do |batch|
      batch if batch.could_flush?
    end
    batches.compact!
    flush_concrete(batches)
  end

  private

  def flush_concrete(batches)
    return if batches.empty?
    names = batches.map { |batch| "#{batch.worker_class} in #{batch.queue}" }
    Sidekiq::Grouping.logger.info(
      "[Sidekiq::Grouping] Trying to flush batched queues: #{names.join(',')}"
    )
    batches.each(&:flush)
  end<commit_msg>add force_flush_for_test! method for tests<commit_after>class Sidekiq::Grouping::Flusher
  def flush
    batches = Sidekiq::Grouping::Batch.all.map do |batch|
      batch if batch.could_flush?
    end
    batches.compact!
    flush_concrete(batches)
  end

  def force_flush_for_test!
    if defined?(::Rails) && Rails.respond_to?(:env) && !Rails.env.test?
      puts("**************************************************")
      puts("⛔️ WARNING: force_flush_for_test! for testing API, but this is not the test environment.")
      puts("**************************************************")
    end
    batches = Sidekiq::Grouping::Batch.all
    batches.compact!
    flush_concrete(batches)
  end

  private

  def flush_concrete(batches)
    return if batches.empty?
    names = batches.map { |batch| "#{batch.worker_class} in #{batch.queue}" }
    Sidekiq::Grouping.logger.info(
      "[Sidekiq::Grouping] Trying to flush batched queues: #{names.join(',')}"
    )
    batches.each(&:flush)
  end
{'fraction_non_alphanumeric': 0.18778726198292844, 'fraction_numerical': 0.0, 'mean_word_length': 3.9161290322580644, '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': '7225454', 'n_tokens_mistral': 509, 'n_tokens_neox': 501, 'n_words': 104}