<commit_before>class SerialsController < ApplicationController
  before_action :set_serial, only: [:show, :update, :destroy]

  # GET /serials
  # GET /serials.json
  def index
    @serials = Serial.all

    render json: @serials
  end

  # GET /serials/1
  # GET /serials/1.json
  def show
    render json: @serial
  end

  # POST /serials
  # POST /serials.json
  def create
    @user = User.find(1)
    @serial = Serial.find(params[:id])
    @user.serials << @serial
    if @serial.save
      render json: @serial, status: :created, location: @serial
    else
      render json: @serial.errors, status: :unprocessable_entity
    end
  end

  # PATCH/PUT /serials/1
  # PATCH/PUT /serials/1.json
  def update
    @serial = Serial.find(params[:id])

    if @serial.update(serial_params)
      render json: @serial
    else
      render json: @serial.errors, status: :unprocessable_entity
    end
  end

  # DELETE /serials/1
  # DELETE /serials/1.json
  def destroy
    @serial.destroy

    @serials = Serial.where(user_id: 1)

    render json: @serials
  end

  def user_serials
    @serials = Serial.where(user_id: 1)
    render json: @serials
  end

  # def all
  #   @allserials = Availableserial.all
  #   render json: @allserials
  # end
  #
  # def all_serials_id
  #   @serial = Availableserial.find(params[:id])
  #   render json: @serial
  # end

  private

    def set_serial
      @serial = Serial.find(params[:id])
    end

    def serial_params
      params.permit(:name)
    end
end<commit_msg>Add delete serials<commit_after>class SerialsController < ApplicationController
  before_action :set_serial, only: [:show, :update, :destroy]

  # GET /serials
  # GET /serials.json
  def index
    @serials = Serial.all

    render json: @serials
  end

  # GET /serials/1
  # GET /serials/1.json
  def show
    render json: @serial
  end

  # POST /serials
  # POST /serials.json
  def create
    @user = User.find(1)
    @serial = Serial.find(params[:id])
    @user.serials << @serial
    if @serial.save
      render json: @serial, status: :created, location: @serial
    else
      render json: @serial.errors, status: :unprocessable_entity
    end
  end

  # PATCH/PUT /serials/1
  # PATCH/PUT /serials/1.json
  def update
    @serial = Serial.find(params[:id])

    if @serial.update(serial_params)
      render json: @serial
    else
      render json: @serial.errors, status: :unprocessable_entity
    end
  end

  # DELETE /serials/1
  # DELETE /serials/1.json
  def destroy
    @user = User.find(1)
    @user.serials.delete(@serial)

    @serials = Serial.where(user_id: 1)

    render json: @serials
  end

  def user_serials
    @serials = Serial.where(user_id: 1)
    render json: @serials
  end

  # def all
  #   @allserials = Availableserial.all
  #   render json: @allserials
  # end
  #
  # def all_serials_id
  #   @serial = Availableserial.find(params[:id])
  #   render json: @serial
  # end

  private

    def set_serial
      @serial = Serial.find(params[:id])
    end

    def serial_params
      params.permit(:name, :description)
    end
end
{'fraction_non_alphanumeric': 0.10883690708252111, 'fraction_numerical': 0.006172839506172839, 'mean_word_length': 2.6874251497005988, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4922421', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1067, 'n_words': 266}