<commit_before>class SubjectsController < ApplicationController
  before_action :set_subject, only: [:show, :edit, :update, :destroy]

  # GET /subjects
  # GET /subjects.json
  def index
    @subjects = Subject.all
  end

  # GET /subjects/1
  # GET /subjects/1.json
  def show
    #public_safety_question = Question.find_by_short_name("public_safety")
    #prop_value_question = Question.find_by_short_name("property_values")
    @questions_raw = Question.where(:short_name => ["public_safety", "property_values"])
    @questions = Array.new
    @questions_raw.each do |q|
      average_priority = FeedbackInput.where(:neighborhood_id => params[:id]).average("numerical_response")
      @questions << OpenStruct.new(:voice_text => q.voice_text , :short_name => q.short_name, :average_priority => average_priority, :question_text => q.question_text)
    end
    @user_voice_messages = Array.new
    3.times do
      @user_voice_messages << OpenStruct.new(:voice_url => "https://s3-us-west-1.amazonaws.com/south-bend-secrets/121gigawatts.mp3", :public_safety => rand(1..5), :property_values => rand(1..5), :phone_number => "1234567890", :date => "06/09/13")
    end
  end

  # GET /subjects/new
  def new
    @subject = Subject.new
  end

  # GET /subjects/1/edit
  def edit
  end

  # POST /subjects
  # POST /subjects.json
  def create
    @subject = Subject.new(subject_params)

    respond_to do |format|
      if @subject.save
        format.html { redirect_to @subject, notice: 'Subject was successfully created.' }
        format.json { render action: 'show', status: :created, location: @subject }
      else
        format.html { render action: 'new' }
        format.json { render json: @subject.errors, status: :unprocessable_entity }
      end<commit_msg>Make averages for numerical questions work correctly<commit_after>class SubjectsController < ApplicationController
  before_action :set_subject, only: [:show, :edit, :update, :destroy]

  # GET /subjects
  # GET /subjects.json
  def index
    @subjects = Subject.all
  end

  # GET /subjects/1
  # GET /subjects/1.json
  def show
    #public_safety_question = Question.find_by_short_name("public_safety")
    #prop_value_question = Question.find_by_short_name("property_values")
    @questions_raw = Question.where(:short_name => ["public_safety", "property_values"])
    @questions = Array.new
    @questions_raw.each do |q|
      average_priority = FeedbackInput.where(:neighborhood_id => params[:id], :question_id => q.id).average("numerical_response")
      @questions << OpenStruct.new(:voice_text => q.voice_text , :short_name => q.short_name, :average_priority => average_priority, :question_text => q.question_text)
    end
    @user_voice_messages = Array.new
    3.times do
      @user_voice_messages << OpenStruct.new(:voice_url => "https://s3-us-west-1.amazonaws.com/south-bend-secrets/121gigawatts.mp3", :public_safety => rand(1..5), :property_values => rand(1..5), :phone_number => "1234567890", :date => "06/09/13")
    end
  end

  # GET /subjects/new
  def new
    @subject = Subject.new
  end

  # GET /subjects/1/edit
  def edit
  end

  # POST /subjects
  # POST /subjects.json
  def create
    @subject = Subject.new(subject_params)

    respond_to do |format|
      if @subject.save
        format.html { redirect_to @subject, notice: 'Subject was successfully created.' }
        format.json { render action: 'show', status: :created, location: @subject }
      else
        format.html { render action: 'new' }
        format.json { render json: @subject.errors, status: :unprocessable_entity }
      end
{'fraction_non_alphanumeric': 0.12600834492350488, 'fraction_numerical': 0.016689847009735744, 'mean_word_length': 3.664072632944228, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 26, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6799998', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1147, 'n_words': 249}