<commit_before>class FeedbacksController < ApplicationController
  before_filter :authenticate_user!, except: [:create]
  before_action :set_feedback, only: [:show, :edit, :update, :destroy]

  protect_from_forgery :except => [:create]

  # GET /feedbacks
  # GET /feedbacks.json
  def index
    @feedbacks = Feedback.all
  end

  # POST /feedbacks
  # POST /feedbacks.json
  def create
    @feedback = Feedback.new(feedback_params)

    post_link = feedback_params[:post_link]

    post = Post.find_by_link(post_link)

    if post == nil
      render :text => "Error: No post found for link" and return
    end

    @feedback.post = post

    respond_to do |format|
      if @feedback.save
        format.json { render :show, status: :created, :text => "OK" }
      else
        format.json { render json: @feedback.errors, status: :unprocessable_entity }
      end
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_feedback
      @feedback = Feedback.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.<commit_msg>expire caches<commit_after>class FeedbacksController < ApplicationController
  before_filter :authenticate_user!, except: [:create]
  before_action :set_feedback, only: [:show, :edit, :update, :destroy]

  protect_from_forgery :except => [:create]

  # GET /feedbacks
  # GET /feedbacks.json
  def index
    @feedbacks = Feedback.all
  end

  # POST /feedbacks
  # POST /feedbacks.json
  def create
    @feedback = Feedback.new(feedback_params)

    post_link = feedback_params[:post_link]

    post = Post.find_by_link(post_link)

    if post == nil
      render :text => "Error: No post found for link" and return
    end

    post.reasons.each do |reason|
      expire_fragment(reason)
    end

    @feedback.post = post

    respond_to do |format|
      if @feedback.save
        format.json { render :show, status: :created, :text => "OK" }
      else
        format.json { render json: @feedback.errors, status: :unprocessable_entity }
      end
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_feedback
      @feedback = Feedback.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
{'fraction_non_alphanumeric': 0.09171974522292993, 'fraction_numerical': 0.0, 'mean_word_length': 3.1188811188811187, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1996279', 'n_tokens_mistral': 750, 'n_tokens_neox': 696, 'n_words': 215}