<commit_before>class ExercisesController < ApplicationController
  #load_and_authorize_resource
  before_action :set_exercise, only: [:show, :update, :destroy]
  load_and_authorize_resource

  # GET /exercises
  # GET /exercises.json
  def index
    @exercises = Exercise.all
    @exercises.each do |exercise|
      authorize! :read, exercise
    end
    render json: @exercises
  end

  # GET /exercises/1
  # GET /exercises/1.json
  def show
    render json: @exercise
  end

  # POST /exercises
  # POST /exercises.json
  def create
    @exercise = Exercise.new(exercise_params)
    authorize! :create, @exercise
    if @exercise.save
       render json: @exercise, status: :created
    else
       render json: @exercise.errors, status: :unprocessable_entity
    end
  end

  # PATCH/PUT /exercises/1
  # PATCH/PUT /exercises/1.json
  def update
    if @exercise.update(exercise_params)
      render json: @exercise, status: :ok
    else
      render json: @exercise.errors, status: :unprocessable_entity
    end
  end

  # DELETE /exercises/1
  # DELETE /exercises/1.json
  def destroy
    @exercise.destroy
    head :no_content
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_exercise
      @exercise = Exercise.find(params[:id])<commit_msg>add deleting exercises<commit_after>class ExercisesController < ApplicationController
  #load_and_authorize_resource
  before_action :set_exercise, only: [:show, :update, :destroy]
  load_and_authorize_resource

  # GET /exercises
  # GET /exercises.json
  def index
    @exercises = Exercise.all
    @exercises.each do |exercise|
      authorize! :read, exercise
    end
    render json: @exercises
  end

  # GET /exercises/1
  # GET /exercises/1.json
  def show
    render json: @exercise
  end

  # POST /exercises
  # POST /exercises.json
  def create
    @exercise = Exercise.new(exercise_params)
    authorize! :create, @exercise
    if @exercise.save
       render json: @exercise, status: :created
    else
       render json: @exercise.errors, status: :unprocessable_entity
    end
  end

  # PATCH/PUT /exercises/1
  # PATCH/PUT /exercises/1.json
  def update
    if @exercise.update(exercise_params)
      render json: @exercise, status: :ok
    else
      render json: @exercise.errors, status: :unprocessable_entity
    end
  end

  # DELETE /exercises/1
  # DELETE /exercises/1.json
  def destroy
    @exercise.destroy
    render json: @exercise
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_exercise
      @exercise = Exercise.find(params[:id])
{'fraction_non_alphanumeric': 0.0859106529209622, 'fraction_numerical': 0.004581901489117984, 'mean_word_length': 3.0809968847352023, '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': '1674690', 'n_tokens_mistral': 895, 'n_tokens_neox': 838, 'n_words': 226}