<commit_before>class CommentsController < ApplicationController
  before_action :set_comment, only: [:show, :edit, :update, :destroy]

 

  # GET /comments/1
  # GET /comments/1.json
  def show
    @comments = Comment.where(lecture_id: params[:lecture_id]).paginate(page: params[:page], per_page:20)
  end

  # GET /comments/new
  def new
    #@comment = Comment.new
  end

  # GET /comments/1/edit
  def edit
  end

  # POST /comments
  # POST /comments.json
  def create
    @comment = Comment.new(comment_params)

    if @comment.save
      render :show, status: :created, location: @comment
    else
      render json: @comment.errors, status: :unprocessable_entity 
    end
  end

  # PATCH/PUT /comments/1
  # PATCH/PUT /comments/1.json
  def update
    if @comment.update(comment_params)
      render :show, status: :ok, location: @comment
    else
      render json: @comment.errors, status: :unprocessable_entity
    end
  end

  # DELETE /comments/1
  # DELETE /comments/1.json
  def destroy
    @comment.destroy
    head :no_content
  end


  def recommend
  
  end


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

    # Never trust parameters from the scary internet, only allow the white list through.
    def comment_params
      params.require(:comment).permit(:user_id, :lecture_id, :content)
    end
end
<commit_msg>apipie 수정<commit_after>class CommentsController < ApplicationController
  before_action :set_comment, only: [:edit, :update, :destroy]

  api :GET, '/comments', '특정 lecture에 대한 댓글'
  param :lecture_id, :number, :desc => "강의 ID", :required => true
  def show
    @comments = Comment.where(lecture_id: params[:lecture_id]).paginate(page: params[:page], per_page:20)
  end


  api :POST, '/comments', '특정 lecture에 대한 댓글 생성'
  param :lecture_id, :number, :desc => "강의 ID", :required => true
  param :content, String, :desc => "댓글 내용", :required => true
  def create
    @comment = Comment.new(comment_params)

    if @comment.save
      render :show, status: :created, location: @comment
    else
      render json: @comment.errors, status: :unprocessable_entity 
    end
  end

  api :GET, '/comments/edit', '댓글 수정 페이지'
  param :id, :number, :desc => "Comment ID", :required => true
    def edit
      if @comment.user_id == session[:user_id]
        render json: @comment, status: :ok
      else
        render json: @comment.errors, status: :forbidden
      end
    end

  # PATCH/PUT /comments.json
  api :PUT, '/comments', '특정 lecture에 대한 댓글 수정'
  param :id, :number, :desc => "Comment ID", :required => true
  param :content, String, :desc => "댓글 내용", :required => true
  def update
    if @comment.update(comment_params)
      render :show, status: :ok, location: @comment
    else
      render json: @comment.errors, status: :unprocessable_entity
    end
  end


  api :DELETE, '/comments', '특정 lecture에 대한 댓글 삭제'
  param :id, :number, :desc => "Comment ID", :required => true
  def destroy
    @comment.destroy
    head :no_content
  end


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

    # Never trust parameters from the scary internet, only allow the white list through.
    def comment_params
      params.require(:comment).permit(:user_id, :lecture_id, :content)
    end
end

{'fraction_non_alphanumeric': 0.112565445026178, 'fraction_numerical': 0.0031995346131471784, 'mean_word_length': 3.204156479217604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '5435056', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1151, 'n_words': 340}