<commit_before>class Role::Admin::GovernsController < Role::Admin::BaseController
  before_action :set_govern, only: [:show, :edit, :update, :move_higher, :move_lower, :destroy]

  def index
    if params[:govern_taxon_id]
      @govern_taxon = GovernTaxon.find params[:govern_taxon_id]
      @governs = @govern_taxon.governs.includes(:rules)
    else
      @governs = Govern.includes(:rules).without_taxon
    end
  end

  def show
  end

  def new
    @govern = Govern.new(govern_taxon_id: params[:govern_taxon_id])
    @options = GovernTaxon.select(:id, :name).all
  end

  def create
    @govern = Govern.new(govern_params)

    respond_to do |format|
      if @govern.save
        format.html { redirect_to admin_governs_url, notice: 'Govern was successfully created.' }
        format.json { render :show, status: :created, location: @govern }
      else
        format.html {
          @options = GovernTaxon.select(:id, :name).all
          render :new
        }
        format.json { render json: @govern.errors, status: :unprocessable_entity }
      end
    end
  end

  def sync
    ControllerGovern.sync_controllers

    redirect_to admin_governs_url
  end

  def edit
    @options = GovernTaxon.select(:id, :name).all
  end

  def update
    @govern.assign_attributes(govern_params)
    respond_to do |format|
      if @govern.save
        format.html { redirect_to admin_governs_url, notice: 'Govern was successfully updated.' }
        format.json { render :show, status: :ok, location: @govern }
      else
        format.html { render :edit }
        format.json { render json: @govern.errors, status: :unprocessable_entity }
      end
    end
  end

  def move_higher
    @govern.move_higher
    redirect_to admin_governs_url(params.to_h)
  end

  def move_lower
    @govern.move_lower
    redirect_to admin_governs_url(params.to_h)
  end

  def destroy
    @govern.destroy
    respond_to do |format|
      format.html { redirect_to admin_governs_url, notice: 'Govern was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
  def set_govern
    @govern = Govern.find(params[:id])
  end

  def govern_params
    params.fetch(:govern, {}).permit(:code, :name, :position, :govern_taxon_id)
  end

end<commit_msg>fix move higher<commit_after>class Role::Admin::GovernsController < Role::Admin::BaseController
  before_action :set_govern, only: [:show, :edit, :update, :move_higher, :move_lower, :destroy]

  def index
    if params[:govern_taxon_id]
      @govern_taxon = GovernTaxon.find params[:govern_taxon_id]
      @governs = @govern_taxon.governs.includes(:rules)
    else
      @governs = Govern.includes(:rules).without_taxon
    end
  end

  def show
  end

  def new
    @govern = Govern.new(govern_taxon_id: params[:govern_taxon_id])
    @options = GovernTaxon.select(:id, :name).all
  end

  def create
    @govern = Govern.new(govern_params)

    respond_to do |format|
      if @govern.save
        format.html { redirect_to admin_governs_url, notice: 'Govern was successfully created.' }
        format.json { render :show, status: :created, location: @govern }
      else
        format.html {
          @options = GovernTaxon.select(:id, :name).all
          render :new
        }
        format.json { render json: @govern.errors, status: :unprocessable_entity }
      end
    end
  end

  def sync
    ControllerGovern.sync_controllers

    redirect_to admin_governs_url
  end

  def edit
    @options = GovernTaxon.select(:id, :name).all
  end

  def update
    @govern.assign_attributes(govern_params)
    respond_to do |format|
      if @govern.save
        format.html { redirect_to admin_governs_url, notice: 'Govern was successfully updated.' }
        format.json { render :show, status: :ok, location: @govern }
      else
        format.html { render :edit }
        format.json { render json: @govern.errors, status: :unprocessable_entity }
      end
    end
  end

  def move_higher
    @govern.move_higher
    redirect_to admin_governs_url(request.query_parameters)
  end

  def move_lower
    @govern.move_lower
    redirect_to admin_governs_url(request.query_parameters)
  end

  def destroy
    @govern.destroy
    respond_to do |format|
      format.html { redirect_to admin_governs_url, notice: 'Govern was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
  def set_govern
    @govern = Govern.find(params[:id])
  end

  def govern_params
    params.fetch(:govern, {}).permit(
      :code,
      :name,
      :position,
      :govern_taxon_id
    )
  end

end
{'fraction_non_alphanumeric': 0.09542483660130718, 'fraction_numerical': 0.0, 'mean_word_length': 2.9956483899042645, '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': '5037111', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1457, 'n_words': 346}