<commit_before>class BackupJob < ActiveRecord::Base
  belongs_to :server
  belongs_to :backup_server
  has_many :commands
  named_scope :running, :conditions => {:finished => false}, :order => 'updated_at DESC', :include => [:server, :backup_server]
  named_scope :queued, :conditions => {:status => 'queued'}, :order => 'created_at ASC', :include => [:server, :backup_server]
  named_scope :latest_problems, :conditions => "status NOT IN ('OK','running','queued')", :order => 'updated_at DESC', :limit => 20, :include => [:server, :backup_server]
  
  def fs
    self.backup_server.zpool + '/' + self.server.hostname
  end
  
  def prepare_fs
     run_command("/sbin/zfs list #{self.fs}", "fs_exists")
  end
  
  def run
    self.status = 'running'
    self.finished = false
    save
    prepare_fs
  end
  
  def ssh_command
    "ssh -c arcfour -p #{self.server.ssh_port}"
  end
  
  def to_rsync
    "/usr/bin/pfexec rsync --stats -aHRW --timeout=600 --delete-excluded --exclude=.zfs -e '#{ssh_command}' " +
    self.server.rsync_includes + " " + self.server.rsync_excludes +
    " --log-file=/tmp/#{self.server}_debug root@#{self.server.connect_address}:#{self.server.startdir} /#{fs}/"
  end
  <commit_msg>Change the order of queued backups<commit_after>class BackupJob < ActiveRecord::Base
  belongs_to :server
  belongs_to :backup_server
  has_many :commands
  named_scope :running, :conditions => {:finished => false}, :order => 'updated_at DESC', :include => [:server, :backup_server]
  named_scope :queued, :conditions => {:status => 'queued'}, :order => 'created_at DESC', :include => [:server, :backup_server]
  named_scope :latest_problems, :conditions => "status NOT IN ('OK','running','queued')", :order => 'updated_at DESC', :limit => 20, :include => [:server, :backup_server]
  
  def fs
    self.backup_server.zpool + '/' + self.server.hostname
  end
  
  def prepare_fs
     run_command("/sbin/zfs list #{self.fs}", "fs_exists")
  end
  
  def run
    self.status = 'running'
    self.finished = false
    save
    prepare_fs
  end
  
  def ssh_command
    "ssh -c arcfour -p #{self.server.ssh_port}"
  end
  
  def to_rsync
    "/usr/bin/pfexec rsync --stats -aHRW --timeout=600 --delete-excluded --exclude=.zfs -e '#{ssh_command}' " +
    self.server.rsync_includes + " " + self.server.rsync_excludes +
    " --log-file=/tmp/#{self.server}_debug root@#{self.server.connect_address}:#{self.server.startdir} /#{fs}/"
  end
  
{'fraction_non_alphanumeric': 0.16121112929623568, 'fraction_numerical': 0.004091653027823241, 'mean_word_length': 3.775390625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6477047', 'n_tokens_mistral': 872, 'n_tokens_neox': 856, 'n_words': 189}