<commit_before>class MxCommonColumnSetsController < ApplicationController
  include MxProjectFixation
  include MxDatabaseFixation
  unloadable

  before_filter :find_common_column_set, only: [:show, :edit, :update, :destroy]

  def index
  end

  def show
  end

  def new
    @common_column_set = MxCommonColumnSet.new
    @vue_model = MxVm::CommonColumnSet.new
    set_data_types_to_vue_model
  end

  def create
    @common_column_set = MxCommonColumnSet.new(database_id: @database.id)
    @vue_model = MxVm::CommonColumnSet.new(params[:mx_common_column_set])
    if @vue_model.valid?
      @common_column_set.save_with!(@vue_model)
      flash[:notice] = l(:notice_successful_create)
      redirect_to project_mx_database_common_column_set_path(@project, @database, @common_column_set)
    else
      set_data_types_to_vue_model
      render action: :new
    end
  end

  def edit
    @vue_model = MxVm::CommonColumnSet.new(@common_column_set)
    set_data_types_to_vue_model
  end

  def update
    @vue_model = MxVm::CommonColumnSet.new(params[:mx_common_column_set])
    if @vue_model.valid?
      @common_column_set.save_with!(@vue_model)
      flash[:notice] = l(:notice_successful_update)
      redirect_to project_mx_database_common_column_set_path(@project, @database, @common_column_set)
    else
      set_data_types_to_vue_model
      render action: :edit
    end
  rescue ActiveRecord::StaleObjectError
    set_data_types_to_vue_model
    flash.now[:error] = l(:notice_locking_conflict)
    render action: :edit
  end

  def destroy

  end

  private

  def find_common_column_set
    @common_column_set = MxCommonColumnSet.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    render_404
  end

  def set_data_types_to_vue_model
    @vue_model.data_types = @database.dbms_product.data_types.map { |data_type| MxVm::DataType.new(data_type) }
  end
end<commit_msg>Add feature that delete common column set<commit_after>class MxCommonColumnSetsController < ApplicationController
  include MxProjectFixation
  include MxDatabaseFixation
  unloadable

  before_filter :find_common_column_set, only: [:show, :edit, :update, :destroy]

  def index
  end

  def show
  end

  def new
    @common_column_set = MxCommonColumnSet.new
    @vue_model = MxVm::CommonColumnSet.new
    set_data_types_to_vue_model
  end

  def create
    @common_column_set = MxCommonColumnSet.new(database_id: @database.id)
    @vue_model = MxVm::CommonColumnSet.new(params[:mx_common_column_set])
    if @vue_model.valid?
      @common_column_set.save_with!(@vue_model)
      flash[:notice] = l(:notice_successful_create)
      redirect_to project_mx_database_common_column_set_path(@project, @database, @common_column_set)
    else
      set_data_types_to_vue_model
      render action: :new
    end
  end

  def edit
    @vue_model = MxVm::CommonColumnSet.new(@common_column_set)
    set_data_types_to_vue_model
  end

  def update
    @vue_model = MxVm::CommonColumnSet.new(params[:mx_common_column_set])
    if @vue_model.valid?
      @common_column_set.save_with!(@vue_model)
      flash[:notice] = l(:notice_successful_update)
      redirect_to project_mx_database_common_column_set_path(@project, @database, @common_column_set)
    else
      set_data_types_to_vue_model
      render action: :edit
    end
  rescue ActiveRecord::StaleObjectError
    set_data_types_to_vue_model
    flash.now[:error] = l(:notice_locking_conflict)
    render action: :edit
  end

  def destroy
    @common_column_set.destroy
    flash[:notice] = l(:notice_successful_delete)
    redirect_to action: :index
  end

  private

  def find_common_column_set
    @common_column_set = MxCommonColumnSet.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    render_404
  end

  def set_data_types_to_vue_model
    @vue_model.data_types = @database.dbms_product.data_types.map { |data_type| MxVm::DataType.new(data_type) }
  end
end
{'fraction_non_alphanumeric': 0.07849654819739198, 'fraction_numerical': 0.001534134492457172, 'mean_word_length': 4.556818181818182, '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': '2646083', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1337, 'n_words': 223}