<commit_before>ActiveAdmin.register BaseJob, as: 'Job' do
  menu parent: "System",  priority: 100

  config.batch_actions = false
  actions :index, :run


  controller do
    def find_resource
      super.becomes(BaseJob)
    end

  end

  member_action :run, method: :put do

     begin
       BaseJob.launch!(resource.id)
       flash[:notice] = "Finished!"
       redirect_to action: :index
     rescue StandardError => e
       logger.warn e.message
       logger.warn e.backtrace.join("\n")
       flash[:warning] = e.message
       redirect_to action: :index
     end

   end

  index do
    id_column
    actions
    column :type
    column :description
    column :executed  do  |row|
      time_ago_in_words(row.updated_at) << " ago"
    end
    column :running
    actions defaults: false do  |row|
           link_to 'Run', run_job_path(row), method: :put,  data: { confirm: "Are you sure?" }
    end

  end


end

<commit_msg>Add unlock button for job. closes #37<commit_after>ActiveAdmin.register BaseJob, as: 'Job' do
  menu parent: "System",  priority: 100

  config.batch_actions = false
  actions :index, :run


  controller do
    def find_resource
      super.becomes(BaseJob)
    end

  end

  member_action :run, method: :put do
     begin
       BaseJob.launch!(resource.id)
       flash[:notice] = "Finished!"
       redirect_to action: :index
     rescue StandardError => e
       logger.warn e.message
       logger.warn e.backtrace.join("\n")
       flash[:warning] = e.message
       redirect_to action: :index
     end
  end

  member_action :unlock, method: :put do
      resource.release_lock!
      redirect_to action: :index
  end


  index do
    id_column
    actions
    column :type
    column :description
    column :executed  do  |row|
      time_ago_in_words(row.updated_at) << " ago"
    end
    column :running
    actions defaults: false do  |row|
      if row.running
        link_to('Unlock', unlock_job_path(row), method: :put,  data: { confirm: "Are you sure?" })
      else
        link_to('Run', run_job_path(row), method: :put,  data: { confirm: "Are you sure?" })
      end

    end

  end


end


{'fraction_non_alphanumeric': 0.09823091247672253, 'fraction_numerical': 0.0037243947858473, 'mean_word_length': 2.4886363636363638, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6401626', 'n_tokens_mistral': 706, 'n_tokens_neox': 675, 'n_words': 194}