<commit_before>class ReplicationsController < ApplicationController

  before_filter :load_replication

  skip_before_filter :verify_authenticity_token, :only => [ :configuration, :start, :stop ]
  skip_before_filter :check_authentication, :only => :configuration

  def configuration
    Replication.authenticate_with_internal_couch_users params[:user_name], params[:password]
    render :json => Replication.couch_config
  end

  def index
    authorize! :read, Replication
    @replications = Replication.all
  end

  def new
    authorize! :create, Replication
    @replication = Replication.new
  end

  def create
    authorize! :create, Replication
    @replication = Replication.new params[:replication]

    if @replication.save
      redirect_to devices_path
    else
      render :new
    end
  end

  def edit
    authorize! :edit, @replication
  end

  def update
    authorize! :update, @replication
    @replication.update_attributes params[:replication]

    if @replication.save
      redirect_to devices_path
    else
      render :edit
    end
  end

  def destroy
    authorize! :destroy, @replication
    @replication.destroy
    redirect_to devices_path
  end

  def start
    authorize! :start, @replication
    @replication.start_replication
    redirect_to devices_path
  end

  def stop
    authorize! :stop, @replication
    @replication.stop_replication
    redirect_to devices_path
  end

  private

  def load_replication<commit_msg>1619 | Subhas | Added a Replication UI just to make development easier<commit_after>class ReplicationsController < ApplicationController

  before_filter :load_replication

  skip_before_filter :verify_authenticity_token, :only => [ :configuration, :start, :stop ]
  skip_before_filter :check_authentication, :only => :configuration

  def configuration
    Replication.authenticate_with_internal_couch_users params[:user_name], params[:password]
    render :json => Replication.couch_config
  end

  def index
    authorize! :read, Replication
    @replications = Replication.all
  end

  def new
    authorize! :create, Replication
    @replication = Replication.new
  end

  def create
    authorize! :create, Replication
    @replication = Replication.new params[:replication]

    if @replication.save
      redirect_to devices_path
    else
      render :new
    end
  end

  def edit
    authorize! :edit, @replication
  end

  def update
    authorize! :update, @replication
    @replication.update_attributes params[:replication]

    if @replication.save
      redirect_to devices_path
    else
      render :edit
    end
  end

  def destroy
    authorize! :destroy, @replication
    @replication.destroy
    redirect_to devices_path
  end

  def start
    authorize! :start, @replication
    @replication.start_replication
    redirect_to devices_path
  end

  def stop
    authorize! :stop, @replication
    @replication.stop_replication
    redirect_to devices_path
  end

  def show
    authorize! :show, @replication
  end

  private

  def load_replication
{'fraction_non_alphanumeric': 0.06324110671936758, 'fraction_numerical': 0.0013175230566534915, 'mean_word_length': 3.5876132930513593, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7546417', 'n_tokens_mistral': 916, 'n_tokens_neox': 877, 'n_words': 233}