<commit_before>#
# Namespace for the Socializer engine
#
module Socializer
  class CommentsController < ApplicationController
    before_action :authenticate_user
    before_action :set_comment, only: [:edit, :update, :destroy]

    def new
      @comment = Comment.new
    end

    def create
      @comment = current_user.comments.build(params[:comment])
      @comment.activity_verb = 'add'
      # TODO: Is scope needed? Try commenting it out to see what happens
      @comment.scope = Audience.privacy.find_value(:public)
      @comment.save!

      flash[:notice] = t('socializer.model.create', model: 'Comment')
      redirect_to activities_path
    end

    def edit
    end

    def update
      @comment.update!(params[:comment])

      flash[:notice] = t('socializer.model.update', model: 'Comment')
      redirect_to activities_path
    end

    def destroy
      @comment.destroy
      redirect_to activities_path
    end

    private

    def set_comment
      @comment = current_user.comments.find_by(id: params[:id])
    end
  end
end<commit_msg>add some documentation to the controller actions<commit_after>#
# Namespace for the Socializer engine
#
module Socializer
  class CommentsController < ApplicationController
    before_action :authenticate_user
    before_action :set_comment, only: [:edit, :update, :destroy]

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

    # POST /comments
    def create
      @comment = current_user.comments.build(params[:comment])
      @comment.activity_verb = 'add'
      # TODO: Is scope needed? Try commenting it out to see what happens
      @comment.scope = Audience.privacy.find_value(:public)
      @comment.save!

      flash[:notice] = t('socializer.model.create', model: 'Comment')
      redirect_to activities_path
    end

    # GET /comments/1/edit
    def edit
    end

    # PATCH/PUT /comments/1
    def update
      @comment.update!(params[:comment])

      flash[:notice] = t('socializer.model.update', model: 'Comment')
      redirect_to activities_path
    end

    # DELETE /comments/1
    def destroy
      @comment.destroy
      redirect_to activities_path
    end

    private

    def set_comment
      @comment = current_user.comments.find_by(id: params[:id])
    end
  end
end
{'fraction_non_alphanumeric': 0.09194395796847636, 'fraction_numerical': 0.0013134851138353765, 'mean_word_length': 2.9464594127806563, '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': '928214', 'n_tokens_mistral': 674, 'n_tokens_neox': 650, 'n_words': 175}