<commit_before>class SurveysController < ApplicationController
  
  # before_filter :is_user_admin_auth, :only =>[ :new, :create]

  before_filter :login_required, :except => [ :help, :help2, :index, :search_variables, :sort_variables, :show, :facets, :category_browse, :show_datasets_for_categories, :collapse_row, :expand_row]
  
  before_filter :find_previous_searches, :only => [ :index]

  before_filter :find_surveys, :only => [ :index, :search_variables ]

  #before_filter :find_survey_auth, :except => [ :index, :new, :create,:survey_preview_ajax, :help ]
  
  before_filter :find_survey, :only => [:show, :edit, :update]

  before_filter :set_parameters_for_sharing_form, :only => [ :new, :edit ]

  before_filter :check_search_parameters, :only => [:search_variables]

  before_filter :rerouted_search, :only => [:show]
  
  before_filter :find_groups, :only => [ :new, :edit ]
  
  before_filter :find_comments, :only => [ :show ]

  before_filter :find_notes, :only => [ :show ]
  
  before_filter :find_groups, :only => [:new_nesstar_datasource]
  
  after_filter :update_last_user_activity
  
  before_filter :find_previous_searches, :only => [ :show ]
  
  #After the user clicks on the 'collapse' for a row in the variable table
  def collapse_row
    variable = Variable.find(params[:id])
    item = variable
    row_name = item.id.to_s
    dataset = Dataset.find(params[:dataset])
    render :partial => 'variables_table_row', :locals=>{:item=>item,:row_name=>row_name, :curr_cycle=>params[:curr_cycle], :dataset=>dataset,:popularity=>params[:popularity], :id=>params[:id], :extract_lineage=>params[:extract_lineage], :extract_id=>params[:extract_id], :lineage=>params[:lineage]}
  end
  #After the user clicks on the drop down for a variable row
  def expand_row
    variable = Variable.find(params[:id])
    item = variable
    row_name = item.id.to_s
    dataset = Dataset.find(params[:dataset])
    render :partial => 'variables_table_expanded_row', :locals=>{:hidden=>false, :item=>item,:row_name=>row_name, :curr_cycle=>params[:curr_cycle], :dataset=>dataset,:popularity=>params[:popularity], :id=>params[:id], :extract_lineage=>params[:extract_lineage], :extract_id=>params[:extract_id], :lineage=>params[:lineage]}
  end
  
  #list of surveys to add to the db
  def add_nesstar_surveys
    respond_to do |format|
      begin
        Delayed::Job.enqueue AddNesstarSurveysJob::StartJobTask.new(params[:datasets], params[:nesstar_url], params[:nesstar_catalog], params[:groups], params[:sharing_scope], current_user.id, base_host)<commit_msg>find previous searches when showing a survey<commit_after>class SurveysController < ApplicationController
  
  # before_filter :is_user_admin_auth, :only =>[ :new, :create]

  before_filter :login_required, :except => [ :help, :help2, :index, :search_variables, :sort_variables, :show, :facets, :category_browse, :show_datasets_for_categories, :collapse_row, :expand_row]
  
  before_filter :find_previous_searches, :only => [ :index, :show ]

  before_filter :find_surveys, :only => [ :index, :search_variables ]

  #before_filter :find_survey_auth, :except => [ :index, :new, :create,:survey_preview_ajax, :help ]
  
  before_filter :find_survey, :only => [:show, :edit, :update]

  before_filter :set_parameters_for_sharing_form, :only => [ :new, :edit ]

  before_filter :check_search_parameters, :only => [:search_variables]

  before_filter :rerouted_search, :only => [:show]
  
  before_filter :find_groups, :only => [ :new, :edit ]
  
  before_filter :find_comments, :only => [ :show ]

  before_filter :find_notes, :only => [ :show ]
  
  before_filter :find_groups, :only => [:new_nesstar_datasource]
  
  after_filter :update_last_user_activity
  
  #After the user clicks on the 'collapse' for a row in the variable table
  def collapse_row
    variable = Variable.find(params[:id])
    item = variable
    row_name = item.id.to_s
    dataset = Dataset.find(params[:dataset])
    render :partial => 'variables_table_row', :locals=>{:item=>item,:row_name=>row_name, :curr_cycle=>params[:curr_cycle], :dataset=>dataset,:popularity=>params[:popularity], :id=>params[:id], :extract_lineage=>params[:extract_lineage], :extract_id=>params[:extract_id], :lineage=>params[:lineage]}
  end
  #After the user clicks on the drop down for a variable row
  def expand_row
    variable = Variable.find(params[:id])
    item = variable
    row_name = item.id.to_s
    dataset = Dataset.find(params[:dataset])
    render :partial => 'variables_table_expanded_row', :locals=>{:hidden=>false, :item=>item,:row_name=>row_name, :curr_cycle=>params[:curr_cycle], :dataset=>dataset,:popularity=>params[:popularity], :id=>params[:id], :extract_lineage=>params[:extract_lineage], :extract_id=>params[:extract_id], :lineage=>params[:lineage]}
  end
  
  #list of surveys to add to the db
  def add_nesstar_surveys
    respond_to do |format|
      begin
        Delayed::Job.enqueue AddNesstarSurveysJob::StartJobTask.new(params[:datasets], params[:nesstar_url], params[:nesstar_catalog], params[:groups], params[:sharing_scope], current_user.id, base_host)
{'fraction_non_alphanumeric': 0.14129158512720155, 'fraction_numerical': 0.0003913894324853229, 'mean_word_length': 6.049655172413793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 76, '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': '3825547', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1681, 'n_words': 344}