<commit_before>class RoomOffersController < ApplicationController
  before_action :authenticate_user!, except: [:show]

  def show
    @room_offer = RoomOffer.find(params[:id])
    @comments = @room_offer.comments.includes(:user, :images).order(created_at: :desc)
  end

  def select
  end

  def new
    @room_offer = RoomOffer.new
    @room_offer.room_offer_prices.build
    @room_offer.assign_attributes(current_user.slice(:first_name, :last_name, :email, :website))
  end

  def create
    @room_offer = RoomOffer.new(room_offer_params)
    @room_offer.user_id = current_user.admin? ? params[:user_id] : current_user.id
    @room_offer.address = Address.from_feature(params[:feature])
    if @room_offer.save
      @room_offer.create_activity(:create, owner: @room_offer.user)
      RoomMailer.new.send_room_online_email(self)
      redirect_to @room_offer
    else
      render 'new'
    end
  end

  def edit
    @room_offer = current_user.room_offers.find(params[:id])
  end

  def update
    @room_offer = current_user.room_offers.find(params[:id])
    if @room_offer.update(room_offer_params)
      redirect_to @room_offer
    else
      render 'edit'
    end
  end

  def destroy
    @room_offer = current_user.room_offers.find(params[:id])
    @room_offer.destroy

    redirect_to rooms_user_path
  end

  private

  def room_offer_params
    params
      .require(:room_offer)
      .permit(
        :offer_type,
        :slogan,
        :rented_area,
        :total_area,
        :room_description,
        :owner_description,
        :tenant_description,
        :wants_collaboration,
        :cover_photo,
        :remove_cover_photo,
        :avatar,
        :remove_avatar,
        :first_name, :last_name, :website, :email, :phone, :location_id,
        images_files: [],
        address_attributes: [
          :id, :street_name, :street_number, :zip, :city
        ],
        room_offer_prices_attributes: [
          :id, :name, :amount, :_destroy
        ],
        room_category_ids: []
    ).merge(
      keyword_list: [params[:suggested_keywords], params[:custom_keywords]].join(", ")
    )
  end
end
<commit_msg>revert mailing task<commit_after>class RoomOffersController < ApplicationController
  before_action :authenticate_user!, except: [:show]

  def show
    @room_offer = RoomOffer.find(params[:id])
    @comments = @room_offer.comments.includes(:user, :images).order(created_at: :desc)
  end

  def select
  end

  def new
    @room_offer = RoomOffer.new
    @room_offer.room_offer_prices.build
    @room_offer.assign_attributes(current_user.slice(:first_name, :last_name, :email, :website))
  end

  def create
    @room_offer = RoomOffer.new(room_offer_params)
    @room_offer.user_id = current_user.admin? ? params[:user_id] : current_user.id
    @room_offer.address = Address.from_feature(params[:feature])
    if @room_offer.save
      @room_offer.create_activity(:create, owner: @room_offer.user)
      redirect_to @room_offer
    else
      render 'new'
    end
  end

  def edit
    @room_offer = current_user.room_offers.find(params[:id])
  end

  def update
    @room_offer = current_user.room_offers.find(params[:id])
    if @room_offer.update(room_offer_params)
      redirect_to @room_offer
    else
      render 'edit'
    end
  end

  def destroy
    @room_offer = current_user.room_offers.find(params[:id])
    @room_offer.destroy

    redirect_to rooms_user_path
  end

  private

  def room_offer_params
    params
      .require(:room_offer)
      .permit(
        :offer_type,
        :slogan,
        :rented_area,
        :total_area,
        :room_description,
        :owner_description,
        :tenant_description,
        :wants_collaboration,
        :cover_photo,
        :remove_cover_photo,
        :avatar,
        :remove_avatar,
        :first_name, :last_name, :website, :email, :phone, :location_id,
        images_files: [],
        address_attributes: [
          :id, :street_name, :street_number, :zip, :city
        ],
        room_offer_prices_attributes: [
          :id, :name, :amount, :_destroy
        ],
        room_category_ids: []
    ).merge(
      keyword_list: [params[:suggested_keywords], params[:custom_keywords]].join(", ")
    )
  end
end

{'fraction_non_alphanumeric': 0.10586011342155009, 'fraction_numerical': 0.0, 'mean_word_length': 2.9933962264150944, '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': '660790', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1395, 'n_words': 243}