<commit_before>module Dossier
  class ReportsController < ApplicationController
    def show
      report = report_class.new(params[:options] || {})
      report.run

      respond_to do |format|
        format.html do
          begin
            render template: "dossier/reports/#{report_class.report_name}", locals: {report: report}
          rescue ActionView::MissingTemplate => e
            render template: 'dossier/reports/show', locals: {report: report}
          end
        end

        format.json do
          render :json => report.results.hashes
        end

        format.csv do
          set_content_disposition!
          self.response_body = StreamCSV.new(report.raw_results.arrays)
        end

        format.xls do
          set_content_disposition!
          self.response_body = Xls.new(report.raw_results.arrays)
        end
      end
    end

    private

    def report_class
      Dossier.name_to_class(params[:report])
    end

    def set_content_disposition!
      headers["Content-Disposition"] = %[attachment;filename=#{params[:report]}-report_#{Time.now.strftime('%m-%d-%Y_%H-%M-%S')}.#{params[:format]}]
    end

  end
end
<commit_msg>Make ReportsController#report_class public. Needed for it to work with Authority.<commit_after>module Dossier
  class ReportsController < ApplicationController
    def show
      report = report_class.new(params[:options] || {})
      report.run

      respond_to do |format|
        format.html do
          begin
            render template: "dossier/reports/#{report_class.report_name}", locals: {report: report}
          rescue ActionView::MissingTemplate => e
            render template: 'dossier/reports/show', locals: {report: report}
          end
        end

        format.json do
          render :json => report.results.hashes
        end

        format.csv do
          set_content_disposition!
          self.response_body = StreamCSV.new(report.raw_results.arrays)
        end

        format.xls do
          set_content_disposition!
          self.response_body = Xls.new(report.raw_results.arrays)
        end
      end
    end

    def report_class
      Dossier.name_to_class(params[:report])
    end

    private

    def set_content_disposition!
      headers["Content-Disposition"] = %[attachment;filename=#{params[:report]}-report_#{Time.now.strftime('%m-%d-%Y_%H-%M-%S')}.#{params[:format]}]
    end

  end
end

{'fraction_non_alphanumeric': 0.10240464344941957, 'fraction_numerical': 0.0, 'mean_word_length': 2.398591549295775, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '924627', 'n_tokens_mistral': 716, 'n_tokens_neox': 688, 'n_words': 139}