<commit_before># frozen_string_literal: true

module Works::XlsxResponse
  extend ActiveSupport::Concern

  included do
    include ActionController::Streaming

    def show_xlsx_response
      if @works.count < 500
        send_data prepare_workbook.stream_xlsx, filename: "werken #{@collection.name}.xlsx"
      else
        if CollectionDownloadWorker.perform_async(download_parameters[:collection_id], download_parameters[:requested_by_user_id], :xlsx, download_parameters[:audience], download_parameters[:fields_to_expose])
          redirect_to collection_path(@collection), notice: "De download wordt voorbereid. U krijgt een bericht (vanuit de berichtenmodule) wanneer u de download gereed is."
        else
          redirect_to collection_path(@collection), alert: "Er ging iets mis bij het genereren van de download, probeer het later nog eens"
        end
      end
    end

    def show_csv_response
      if @works.count < 500
        send_data prepare_workbook.sheet.table.to_csv, filename: "werken #{@collection.name}.csv"
      else
        if CollectionDownloadWorker.perform_async(download_parameters[:collection_id], download_parameters[:requested_by_user_id], :csv, download_parameters[:audience], download_parameters[:fields_to_expose])
          redirect_to collection_path(@collection), notice: "De download wordt voorbereid. U krijgt een bericht (vanuit de berichtenmodule) wanneer u de download gereed is."
        else<commit_msg>fix: typo<commit_after># frozen_string_literal: true

module Works::XlsxResponse
  extend ActiveSupport::Concern

  included do
    include ActionController::Streaming

    def show_xlsx_response
      if @works.count < 500
        send_data prepare_workbook.stream_xlsx, filename: "werken #{@collection.name}.xlsx"
      else
        if CollectionDownloadWorker.perform_async(download_parameters[:collection_id], download_parameters[:requested_by_user_id], :xlsx, download_parameters[:audience], download_parameters[:fields_to_expose])
          redirect_to collection_path(@collection), notice: "De download wordt voorbereid. U krijgt een bericht (vanuit de berichtenmodule) wanneer de download gereed is."
        else
          redirect_to collection_path(@collection), alert: "Er ging iets mis bij het genereren van de download, probeer het later nog eens"
        end
      end
    end

    def show_csv_response
      if @works.count < 500
        send_data prepare_workbook.sheet.table.to_csv, filename: "werken #{@collection.name}.csv"
      else
        if CollectionDownloadWorker.perform_async(download_parameters[:collection_id], download_parameters[:requested_by_user_id], :csv, download_parameters[:audience], download_parameters[:fields_to_expose])
          redirect_to collection_path(@collection), notice: "De download wordt voorbereid. U krijgt een bericht (vanuit de berichtenmodule) wanneer de download gereed is."
        else
{'fraction_non_alphanumeric': 0.07673778389538885, 'fraction_numerical': 0.0041293874741913286, 'mean_word_length': 4.4849056603773585, 'pattern_counts': {'":': 0, '<': 7, '<?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': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1870055', 'n_tokens_mistral': 820, 'n_tokens_neox': 817, 'n_words': 214}