<commit_before>class ResourceImportFilesController < ApplicationController
  before_filter :check_client_ip_address
  load_and_authorize_resource

  # GET /resource_import_files
  # GET /resource_import_files.xml
  def index
    @resource_import_files = ResourceImportFile.page(params[:page])

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @resource_import_files }
    end
  end

  # GET /resource_import_files/1
  # GET /resource_import_files/1.xml
  def show
    if @resource_import_file.resource_import.path
      unless configatron.uploaded_file.storage == :s3
        file = @resource_import_file.resource_import.path
      end
    end

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @resource_import_file }
      format.download {
        if configatron.uploaded_file.storage == :s3
          redirect_to @resource_import_file.resource_import.expiring_url(10)
        else
          send_file file, :filename => @resource_import_file.resource_import_file_name, :type => 'application/octet-stream'
        end
      }
    end
  end

  # GET /resource_import_files/new
  # GET /resource_import_files/new.xml
  def new
    @resource_import_file = ResourceImportFile.new
    @file_path = root_url + configatron.resource_import_template
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @resource_import_file }
    end
  end

  # GET /resource_import_files/1/edit
  def edit
  end

  # POST /resource_import_files
  # POST /resource_import_files.xml
  def create
    @resource_import_file = ResourceImportFile.new(params[:resource_import_file])
    @resource_import_file.user = current_user

    respond_to do |format|
      if @resource_import_file.save
        flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.resource_import_file'))
        format.html { redirect_to(@resource_import_file) }
        format.xml  { render :xml => @resource_import_file, :status => :created, :location => @resource_import_file }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @resource_import_file.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /resource_import_files/1
  # PUT /resource_import_files/1.xml
  def update
    respond_to do |format|
      if @resource_import_file.update_attributes(params[:resource_import_file])
        flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.resource_import_file'))
        format.html { redirect_to(@resource_import_file) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @resource_import_file.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /resource_import_files/1
  # DELETE /resource_import_files/1.xml
  def destroy
    @resource_import_file.destroy

    respond_to do |format|
      format.html { redirect_to(resource_import_files_url) }
      format.xml  { head :ok }
    end
  end

  def import_request
    @resource_import_file = ResourceImportFile.find(params[:id])
    ResourceImportFile.send_later(:import, @resource_import_file.id, 0)
    flash[:message] = t('resource_import_file.start_importing')
    respond_to do |format|
      format.html {redirect_to(resource_import_file_resource_import_results_path(@resource_import_file))}
    end
  end
end<commit_msg>refs 2796 modified for failure to send process to delayed_job<commit_after>class ResourceImportFilesController < ApplicationController
  before_filter :check_client_ip_address
  load_and_authorize_resource

  # GET /resource_import_files
  # GET /resource_import_files.xml
  def index
    @resource_import_files = ResourceImportFile.page(params[:page])

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @resource_import_files }
    end
  end

  # GET /resource_import_files/1
  # GET /resource_import_files/1.xml
  def show
    if @resource_import_file.resource_import.path
      unless configatron.uploaded_file.storage == :s3
        file = @resource_import_file.resource_import.path
      end
    end

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @resource_import_file }
      format.download {
        if configatron.uploaded_file.storage == :s3
          redirect_to @resource_import_file.resource_import.expiring_url(10)
        else
          send_file file, :filename => @resource_import_file.resource_import_file_name, :type => 'application/octet-stream'
        end
      }
    end
  end

  # GET /resource_import_files/new
  # GET /resource_import_files/new.xml
  def new
    @resource_import_file = ResourceImportFile.new
    @file_path = root_url + configatron.resource_import_template
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @resource_import_file }
    end
  end

  # GET /resource_import_files/1/edit
  def edit
  end

  # POST /resource_import_files
  # POST /resource_import_files.xml
  def create
    @resource_import_file = ResourceImportFile.new(params[:resource_import_file])
    @resource_import_file.user = current_user

    respond_to do |format|
      if @resource_import_file.save
        flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.resource_import_file'))
        format.html { redirect_to(@resource_import_file) }
        format.xml  { render :xml => @resource_import_file, :status => :created, :location => @resource_import_file }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @resource_import_file.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /resource_import_files/1
  # PUT /resource_import_files/1.xml
  def update
    respond_to do |format|
      if @resource_import_file.update_attributes(params[:resource_import_file])
        flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.resource_import_file'))
        format.html { redirect_to(@resource_import_file) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @resource_import_file.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /resource_import_files/1
  # DELETE /resource_import_files/1.xml
  def destroy
    @resource_import_file.destroy

    respond_to do |format|
      format.html { redirect_to(resource_import_files_url) }
      format.xml  { head :ok }
    end
  end

  def import_request
    begin
      @resource_import_file = ResourceImportFile.find(params[:id])
      ResourceImportFile.send_later(:import, @resource_import_file.id, 0)
      flash[:message] = t('resource_import_file.start_importing')
    rescue Exception => e
      logger.error "Failed to send process to delayed_job: #{e}"
    end 
    respond_to do |format|
      format.html {redirect_to(resource_import_file_resource_import_results_path(@resource_import_file))}
    end
  end
end
{'fraction_non_alphanumeric': 0.09162958843159065, 'fraction_numerical': 0.00389321468298109, 'mean_word_length': 3.412883435582822, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 40}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3865487', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2209, 'n_words': 427}