<commit_before>class StudentsController < ApplicationController

  def new
    @student = Student.new
    @view_only = false
    render :profile
  end

  def show
    @student = Student.find(params[:id])
    @view_only = true
    render :profile
  end

  # TODO: Form validation!!
  def create
  	s = params[:student]
    # Remove empty skill and course ids, cause they appear for
    # some weird and unknown reason
    if s.has_key? :skill_ids
      s[:skill_ids] = s[:skill_ids].select { |sk| not sk.empty?}
      puts s[:skill_ids].size
    end

    if s.has_key? :course_ids
      s[:course_ids] = s[:course_ids].select { |c| not c.empty?}
    end

    if s[:name] != '' and s[:about] != '' and s[:interest] != ''
  	  @student = Student.create(:name => s[:name], :about => s[:about],
  		  :interest => s[:interest])
  	  @student.section = Section.find(s[:section_id])
 	    @student.skills << Skill.find(s[:skill_ids])
  	  @student.courses << Course.find(s[:course_ids])
  	  @student.save
      @view_only = true
      redirect_to "/students/#{@student.id}"
    else
      @missing = [:name,:about,:interest].select{ |e| s[e] == '' }.map{ |e| e.to_s }.join ', '
      flash[:notice] = "Please fill in the following fields: " + @missing
      redirect_to students_new_path
    end
  end

  def search
    name_query = params[:query] || ""
    page = params[:page] || 1

    # TODO: if other settings, filter by them

    # Construct sql query
    num_pages, sql_query = Student.search_by_name(name_query, page)

    # Flash variables
    flash[:query] = name_query<commit_msg>Changed interests to not required<commit_after>class StudentsController < ApplicationController

  def new
    @student = Student.new
    @view_only = false
    render :profile
  end

  def show
    @student = Student.find(params[:id])
    @view_only = true
    render :profile
  end

  # TODO: Form validation!!
  def create
  	s = params[:student]
    # Remove empty skill and course ids, cause they appear for
    # some weird and unknown reason
    if s.has_key? :skill_ids
      s[:skill_ids] = s[:skill_ids].select { |sk| not sk.empty?}
      puts s[:skill_ids].size
    end

    if s.has_key? :course_ids
      s[:course_ids] = s[:course_ids].select { |c| not c.empty?}
    end

    if s[:name] != '' and s[:about] != ''
  	  @student = Student.create(:name => s[:name], :about => s[:about],
  		  :interest => s[:interest])
  	  @student.section = Section.find(s[:section_id])
 	    @student.skills << Skill.find(s[:skill_ids])
  	  @student.courses << Course.find(s[:course_ids])
  	  @student.save
      @view_only = true
      redirect_to "/students/#{@student.id}"
    else
      @missing = [:name,:about,:interest].select{ |e| s[e] == '' }.map{ |e| e.to_s }.join ', '
      flash[:notice] = "Please fill in the following fields: " + @missing
      redirect_to students_new_path
      # TODO: Persist params in flash and retrieve them from the view
    end
  end

  def search
    name_query = params[:query] || ""
    page = params[:page] || 1

    # TODO: if other settings, filter by them

    # Construct sql query
    num_pages, sql_query = Student.search_by_name(name_query, page)

    # Flash variables
    flash[:query] = name_query
{'fraction_non_alphanumeric': 0.1380908248378128, 'fraction_numerical': 0.0006178560395427865, 'mean_word_length': 2.9730061349693253, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '6121272', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1073, 'n_words': 278}