<commit_before>require 'find'

class OscJob < ActiveRecord::Base
  has_many :jobs, class_name: "OscJobJob", dependent: :destroy
  has_machete_workflow_of :jobs

  attr_accessor :staging_template_dir

  # Name that defines the template/target dirs
  #def staging_template_name
  #  "osc_jobs"
  #end

  def staged_script_name
    self.script_name
  end

  def script_path
    Pathname.new(self.staged_dir).join(self.script_name)
  end

  def script_path=(new_path)
    unless self.staged_dir.nil?
      path = Pathname.new(new_path)
      staged = Pathname.new(self.staged_dir)
      self.script_name = path.relative_path_from(staged).to_s
    end
  end

  # def staging_template_dir
  #   File.dirname(self.script_path)
  # end

  def folder_contents
    dir = self.staged_dir || Dir.home
    file_paths = []
    Find.find(dir) do |path|<commit_msg>add override to stage to prevent restaging on submit<commit_after>require 'find'

class OscJob < ActiveRecord::Base
  has_many :jobs, class_name: "OscJobJob", dependent: :destroy
  has_machete_workflow_of :jobs

  attr_accessor :staging_template_dir

  # Name that defines the template/target dirs
  #def staging_template_name
  #  "osc_jobs"
  #end

  def staged_script_name
    self.script_name
  end

  def script_path
    Pathname.new(self.staged_dir).join(self.script_name)
  end

  def script_path=(new_path)
    unless self.staged_dir.nil?
      path = Pathname.new(new_path)
      staged = Pathname.new(self.staged_dir)
      self.script_name = path.relative_path_from(staged).to_s
    end
  end

  # Override of OSC::Machete#stage
  # Creates a new staging target job directory on the system
  # Copies the staging template directory to the staging target job directory
  #
  # @return [Pathname] The staged directory path.
  def stage
    unless self.staged_dir
      self.staged_dir = OSC::Machete::JobDir.new(staging_target_dir).new_jobdir
      FileUtils.mkdir_p self.staged_dir
      FileUtils.cp_r staging_template_dir.to_s + "/.", self.staged_dir
    end
    Pathname.new(self.staged_dir)
  end

  # def staging_template_dir
  #   File.dirname(self.script_path)
  # end

  def folder_contents
    dir = self.staged_dir || Dir.home
    file_paths = []
    Find.find(dir) do |path|
{'fraction_non_alphanumeric': 0.08377896613190731, 'fraction_numerical': 0.0, 'mean_word_length': 3.6770833333333335, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '729571', 'n_tokens_mistral': 811, 'n_tokens_neox': 776, 'n_words': 167}