<commit_before>class Admin::ExtensionsController < ApplicationController
  before_filter :login_required 
  before_filter :check_go_live 
  layout 'admin/home'
  def index
    @extensions = Extension.all
  end

  def new
    @extension = Extension.new
  end

  def create
    @extension = Extension.new(params[:extension])
    @extension.installed_by = current_user
    @extension.save!

    redirect_to admin_extensions_path
  end

  def edit
    @extension = Extension.find(params[:id])
  end

  def update
    @extension = Extension.find(params[:id])
    @extension.update_attributes(params[:extension])

    redirect_to admin_extensions_path
  end

  def update_plugin
    @extension = Extension.find(params[:id])
    # install the plugin
    path = 'ruby script/plugin install --force ' + @extension.repository_path 
    system(path)

    redirect_to admin_extensions_path
  end

  def install
    @extension = Extension.find(params[:id])
    # install the plugin
    path = 'ruby script/plugin install ' + @extension.repository_path 
    system(path)

    # execute the load.rb file from installed plugin to run the generators (migration etc)
    path = 'ruby vendor/plugins/' + @extension.display_name + '/load.rb ' + @extension.id.to_s
    system(path)

    redirect_to admin_extensions_path
  end

  def destroy
    @extension = Extension.find(params[:id])
    path = 'ruby script/plugin remove ' + @extension.display_name
    system(path)
    Extension.find(params[:id]).destroy

    redirect_to admin_extensions_path
  end

end<commit_msg>add a check if the plugin is already installed then only run the migrations<commit_after>class Admin::ExtensionsController < ApplicationController
  before_filter :login_required 
  before_filter :check_go_live 
  layout 'admin/home'
  def index
    @extensions = Extension.all
  end

  def new
    @extension = Extension.new
  end

  def create
    @extension = Extension.new(params[:extension])
    @extension.installed_by = current_user
    @extension.save!

    redirect_to admin_extensions_path
  end

  def edit
    @extension = Extension.find(params[:id])
  end

  def update
    @extension = Extension.find(params[:id])
    @extension.update_attributes(params[:extension])

    redirect_to admin_extensions_path
  end

  def update_plugin
    @extension = Extension.find(params[:id])
    # install the plugin
    path = 'ruby script/plugin install --force ' + @extension.repository_path 
    system(path)

    redirect_to admin_extensions_path
  end

  def install
    @extension = Extension.find(params[:id])
    # install the plugin
    if (!File.exist?(File.join('./vendor/plugin','employee','load.rb'))
      path = 'ruby script/plugin install ' + @extension.repository_path 
      system(path)
    end

    # execute the load.rb file from installed plugin to run the generators (migration etc)
    path = 'ruby vendor/plugins/' + @extension.display_name + '/load.rb ' + @extension.id.to_s
    system(path)

    redirect_to admin_extensions_path
  end

  def destroy
    @extension = Extension.find(params[:id])
    path = 'ruby script/plugin remove ' + @extension.display_name
    system(path)
    Extension.find(params[:id]).destroy

    redirect_to admin_extensions_path
  end

end
{'fraction_non_alphanumeric': 0.09211337030191004, 'fraction_numerical': 0.0, 'mean_word_length': 3.6187766714082503, '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': '3740045', 'n_tokens_mistral': 960, 'n_tokens_neox': 914, 'n_words': 235}