<commit_before>class AnnotationsController < ApplicationController
  skip_before_action :verify_authenticity_token
  load_and_authorize_resource

  def create
    @annotation = Annotation.new(annotation_params)
    @annotation.user = current_user
    if @annotation.save
      render json: @annotation.to_json
    end
  end

  def update
    @annotation = Annotation.find!(params[:id])
    if @annotation.update_attributes(annotation_params)
      render json: @annotation.to_json
    end
  end

  def destroy
    @annotation = Annotation.find!(params[:id])
    @annotation.destroy
    render json: { status: :ok }
  end

  def search
    @annotations = Annotation.where(legislation_id: params[:legislation_id])
    annotations_hash = { total: @annotations.size, rows: @annotations }
    render json: annotations_hash.to_json
  end

  private

  def annotation_params
    params
      .require(:annotation)
      .permit(:quote, :text, ranges: [:start, :startOffset, :end, :endOffset])
      .merge(legislation_id: params[:legislation_id], user_id: params[:user_id])
  end
end<commit_msg>Do not accept user_id as parameter when creating annotations<commit_after>class AnnotationsController < ApplicationController
  skip_before_action :verify_authenticity_token
  load_and_authorize_resource

  def create
    @annotation = Annotation.new(annotation_params)
    @annotation.user = current_user
    if @annotation.save
      render json: @annotation.to_json
    end
  end

  def update
    @annotation = Annotation.find!(params[:id])
    if @annotation.update_attributes(annotation_params)
      render json: @annotation.to_json
    end
  end

  def destroy
    @annotation = Annotation.find!(params[:id])
    @annotation.destroy
    render json: { status: :ok }
  end

  def search
    @annotations = Annotation.where(legislation_id: params[:legislation_id])
    annotations_hash = { total: @annotations.size, rows: @annotations }
    render json: annotations_hash.to_json
  end

  private

  def annotation_params
    params
      .require(:annotation)
      .permit(:quote, :text, ranges: [:start, :startOffset, :end, :endOffset])
      .merge(legislation_id: params[:legislation_id])
  end
end
{'fraction_non_alphanumeric': 0.09153005464480875, 'fraction_numerical': 0.0, 'mean_word_length': 4.02745995423341, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2388481', 'n_tokens_mistral': 664, 'n_tokens_neox': 642, 'n_words': 149}