<commit_before>class ImportsController < ApplicationController
  protect_from_forgery :except => [ :data_index, :create ]

  before_authorization_filter :find_resource, :except => [:data_index, :create]
  before_authorization_filter :find_user,     :only   => [:data_index, :create]
  before_authorization_filter :find_sample,   :except => [:show]

  permit :index               do may_edit            end
  permit :show                do may_view(@import)   end
  permit :new                 do may_edit(@sample)   end
  permit :data_index, :create do legitimate_uploader end
  
  private

  def find_sample
    @project ||= Project.where(:name => params[:project])
    sid = params[:sample_id]
    @sample = if sid
                Sample.where(:id => sid).first
              else
                @project.samples.where(:name => params[:sample]).first
              end
  end

  public

  def index
    @imports = @sample.imports.select { |i| may_view i }
  end

  def show
  end
  
  def data_index
    respond_to do |format|<commit_msg>Imports controller: bug fix in find_sample()<commit_after>class ImportsController < ApplicationController
  protect_from_forgery :except => [ :data_index, :create ]

  before_authorization_filter :find_resource, :except => [:data_index, :create]
  before_authorization_filter :find_user,     :only   => [:data_index, :create]
  before_authorization_filter :find_sample,   :except => [:show]

  permit :index               do may_edit            end
  permit :show                do may_view(@import)   end
  permit :new                 do may_edit(@sample)   end
  permit :data_index, :create do legitimate_uploader end
  
  private

  def find_sample
    @project ||= Project.where(:name => params[:project]).first
    sid = params[:sample_id]
    @sample = if sid
                Sample.where(:id => sid).first
              else
                @project.samples.where(:name => params[:sample]).first
              end
  end

  public

  def index
    @imports = @sample.imports.select { |i| may_view i }
  end

  def show
  end
  
  def data_index
    respond_to do |format|
{'fraction_non_alphanumeric': 0.09730751062824752, 'fraction_numerical': 0.0, 'mean_word_length': 2.5596638655462183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1671876', 'n_tokens_mistral': 634, 'n_tokens_neox': 622, 'n_words': 158}