<commit_before>require File.dirname(__FILE__) + '/support/setup'

class BackupDatabase < CloudCrowd::Action

  def process
    date      = Date.today.to_s
    config    = Rails::Configuration.new.database_configuration[Rails.env]
    db        = config['database']
    host      = config['host'] ? "-h #{config['host']}" : ''
    username  = config['username']
    pass      = config['password']
    Dir.mktmpdir do |temp_dir|
      dump    = File.join(temp_dir, "#{db}.dump")
      system "PGPASSWORD=\"#{pass}\" pg_dump -U #{username} #{host} -Fc #{db} > #{dump}"
      DC::Store::AssetStore.new.save_database_backup('dcloud', dump)
      db      = ANALYTICS_DB[Rails.env]
      dump    = File.join(temp_dir, "#{db}.dump")
      system "PGPASSWORD=\"#{pass}\" pg_dump -U #{username} #{host} -Fc #{db} > #{dump}"
      DC::Store::AssetStore.new.save_database_backup('analytics', dump)
    end
    true
  end

end<commit_msg>fixing db config in backup job<commit_after>require File.dirname(__FILE__) + '/support/setup'

class BackupDatabase < CloudCrowd::Action

  def process
    date      = Date.today.to_s
    config    = Rails::Configuration.new.database_configuration[Rails.env]
    db        = MAIN_DB[Rails.env]['database']
    host      = config['host'] ? "-h #{config['host']}" : ''
    username  = config['username']
    pass      = config['password']
    Dir.mktmpdir do |temp_dir|
      dump    = File.join(temp_dir, "#{db}.dump")
      system "PGPASSWORD=\"#{pass}\" pg_dump -U #{username} #{host} -Fc #{db} > #{dump}"
      DC::Store::AssetStore.new.save_database_backup('dcloud', dump)
      db      = ANALYTICS_DB[Rails.env]['database']
      dump    = File.join(temp_dir, "#{db}.dump")
      system "PGPASSWORD=\"#{pass}\" pg_dump -U #{username} #{host} -Fc #{db} > #{dump}"
      DC::Store::AssetStore.new.save_database_backup('analytics', dump)
    end
    true
  end

end
{'fraction_non_alphanumeric': 0.17292437863564253, 'fraction_numerical': 0.0, 'mean_word_length': 3.1766004415011038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6514575', 'n_tokens_mistral': 641, 'n_tokens_neox': 634, 'n_words': 122}