<commit_before>namespace :db do
  desc "Refreshes your local development environment to the current production database" 
  task :production_data_refresh do
    db.database_dump
    db.remote_db_download
    db.production_data_load
    db.remote_db_cleanup
  end 

  # Dump the current database to a MySQL file
  task :database_dump, :roles => :db, :only => { :primary => true } do
    load 'config/environment.rb'
    abcs = ActiveRecord::Base.configurations
    run("mkdir -p db")
    run("mysqldump -u #{abcs["production"]["username"]} -p#{abcs["production"]["password"]} --compress --ignore-table=#{abcs["production"]["database"]}.posts #{abcs["production"]["database"]} > db/production.sql")
    run("rm -f db/production.sql.bz2")
    run("bzip2 db/production.sql")
  end

  # Downloads db/production_data.sql from the remote production environment to your local machine
  task :remote_db_download, :roles => :db, :only => { :primary => true } do
    system "rm -f db/production.sql.bz2"
    get "db/production.sql.bz2", "db/production.sql.bz2"
  end

  # Load the production data downloaded into db/production_data.sql into your local development database
  # By default, delete downloaded SQL. To keep it, set SAVE=true. Example:
  # cap production_data_refresh SAVE=true
  task :production_data_load, :roles => :db, :only => { :primary => true } do
    system "rm -f db/production.sql"
    system "bzip2 -d db/production.sql.bz2"
    load 'config/environment.rb'
    abcs = ActiveRecord::Base.configurations
    `mysql -u #{abcs[RAILS_ENV]["username"]} #{abcs[RAILS_ENV]["database"]} < db/production.sql`
    exec("rm db/production.sql") unless ENV["SAVE"]
  end

   #Cleans up data dump file
  task :remote_db_cleanup, :roles => :db, :only => { :primary => true } do  
    run "rm db/production.sql.bz2"
  end 
end<commit_msg>Don't nuke SQL file if SAVE is set. And don't try to un-bzip file that isn't there<commit_after>namespace :db do
  desc "Refreshes your local development environment to the current production database" 
  task :production_data_refresh do
    db.database_dump
    db.remote_db_download
    db.production_data_load
    db.remote_db_cleanup
  end 

  # Dump the current database to a MySQL file
  task :database_dump, :roles => :db, :only => { :primary => true } do
    load 'config/environment.rb'
    abcs = ActiveRecord::Base.configurations
    run("mkdir -p db")
    run("mysqldump -u #{abcs["production"]["username"]} -p#{abcs["production"]["password"]} --compress --ignore-table=#{abcs["production"]["database"]}.posts #{abcs["production"]["database"]} > db/production.sql")
    run("rm -f db/production.sql.bz2")
    run("bzip2 db/production.sql")
  end

  # Downloads db/production_data.sql from the remote production environment to your local machine
  task :remote_db_download, :roles => :db, :only => { :primary => true } do
    system "rm -f db/production.sql.bz2"
    get "db/production.sql.bz2", "db/production.sql.bz2"
  end

  # Load the production data downloaded into db/production_data.sql into your local development database
  # By default, delete downloaded SQL. To keep it, set SAVE=true. Example:
  # cap production_data_refresh SAVE=true
  task :production_data_load, :roles => :db, :only => { :primary => true } do
    system "rm -f db/production.sql" unless ENV["SAVE"]
    system "bzip2 -d db/production.sql.bz2" if File.exists?("production.sql.bz2")
    load 'config/environment.rb'
    abcs = ActiveRecord::Base.configurations
    `mysql -u #{abcs[RAILS_ENV]["username"]} #{abcs[RAILS_ENV]["database"]} < db/production.sql`
    exec("rm db/production.sql") unless ENV["SAVE"]
  end

   #Cleans up data dump file
  task :remote_db_cleanup, :roles => :db, :only => { :primary => true } do  
    run "rm db/production.sql.bz2"
  end 
end
{'fraction_non_alphanumeric': 0.13619599578503688, 'fraction_numerical': 0.004478398314014752, 'mean_word_length': 4.009234828496043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2913384', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1231, 'n_words': 339}