<commit_before>class ConversationsController < ApplicationController
  before_action :authenticate_user!
  before_action :set_conversation, only: [:show, :edit, :update, :destroy]
  layout 'dashboard'

  # # GET /conversations
  # # GET /conversations.json
  # def index
  #   @conversations = Conversation.all
  # end

  # GET /conversations/1
  # GET /conversations/1.json
  def show
    # make sure the user is authorized to view this conversation
    authorize @conversation

    # update the last accessed times
    @conversation.initiator == current_user ? @conversation.opened_by_initiator : @conversation.opened_by_recipient

    # Build a new message for this conversation
    @message = Message.new
    @message.conversation = @conversation
  end

  # # GET /conversations/new
  # def new
  #   @conversation = Conversation.new
  # end

  # # GET /conversations/1/edit
  # def edit
  # end

  # POST /conversations
  # POST /conversations.json
  def create
    @conversation = Conversation.new(conversation_params)
    @conversation.initiator = current_user
    @conversation.recipient = recipient_from_params

    message = Message.new(message_params)
    message.sender = current_user
    @conversation.messages << message

    authorize @conversation
    if @conversation.save
      redirect_to :back, notice: 'Conversation was successfully created.'
    else
      redirect_to :back, notice: 'Conversation was not sent!'
    end
  end

  # # PATCH/PUT /conversations/1
  # # PATCH/PUT /conversations/1.json
  # def update
  #   respond_to do |format|
  #     if @conversation.update(conversation_params)
  #       format.html { redirect_to @conversation, notice: 'Conversation was successfully updated.' }
  #       format.json { render :show, status: :ok, location: @conversation }
  #     else
  #       format.html { render :edit }
  #       format.json { render json: @conversation.errors, status: :unprocessable_entity }
  #     end
  #   end
  # end

  # # DELETE /conversations/1
  # # DELETE /conversations/1.json
  # def destroy<commit_msg>Upon a successful conversation redirect to the conversation<commit_after>class ConversationsController < ApplicationController
  before_action :authenticate_user!
  before_action :set_conversation, only: [:show, :edit, :update, :destroy]
  layout 'dashboard'

  # # GET /conversations
  # # GET /conversations.json
  # def index
  #   @conversations = Conversation.all
  # end

  # GET /conversations/1
  # GET /conversations/1.json
  def show
    # make sure the user is authorized to view this conversation
    authorize @conversation

    # update the last accessed times
    @conversation.initiator == current_user ? @conversation.opened_by_initiator : @conversation.opened_by_recipient

    # Build a new message for this conversation
    @message = Message.new
    @message.conversation = @conversation
  end

  # # GET /conversations/new
  # def new
  #   @conversation = Conversation.new
  # end

  # # GET /conversations/1/edit
  # def edit
  # end

  # POST /conversations
  # POST /conversations.json
  def create
    @conversation = Conversation.new(conversation_params)
    @conversation.initiator = current_user
    @conversation.recipient = recipient_from_params

    message = Message.new(message_params)
    message.sender = current_user
    @conversation.messages << message

    authorize @conversation
    if @conversation.save
      redirect_to @conversation, notice: 'Yayy!! Message sent, waiting for a reply!'
    else
      redirect_to :back, notice: 'Conversation was not sent!'
    end
  end

  # # PATCH/PUT /conversations/1
  # # PATCH/PUT /conversations/1.json
  # def update
  #   respond_to do |format|
  #     if @conversation.update(conversation_params)
  #       format.html { redirect_to @conversation, notice: 'Conversation was successfully updated.' }
  #       format.json { render :show, status: :ok, location: @conversation }
  #     else
  #       format.html { render :edit }
  #       format.json { render json: @conversation.errors, status: :unprocessable_entity }
  #     end
  #   end
  # end

  # # DELETE /conversations/1
  # # DELETE /conversations/1.json
  # def destroy
{'fraction_non_alphanumeric': 0.0910829548171169, 'fraction_numerical': 0.0033468802295003584, 'mean_word_length': 3.269387755102041, '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': '3509439', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1266, 'n_words': 325}