diff --git a/lib/tasks/accounts.rake b/lib/tasks/accounts.rake deleted file mode 100644 index fb79a27302b9a609377d4656cfaaefcde0b42b70..0000000000000000000000000000000000000000 --- a/lib/tasks/accounts.rake +++ /dev/null @@ -1,15 +0,0 @@ -namespace :accounts do - desc "Run deletions" - task :run_deletions => :environment do - if ::AccountDeletion.uncompleted.count > 0 - puts "Running account deletions.." - ::AccountDeletion.uncompleted.find_each do |account_delete| - account_delete.perform! - end - puts "OK." - else - puts "No acccount deletions to run." - end - end - -end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index d91a6123b5197ddbf54a9e85f2d276dd38a7fbbc..defd67ce70253b61aa1bb09ba80373f446c74875 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -3,92 +3,15 @@ # the COPYRIGHT file. namespace :db do - desc "rebuild and prepare test db" - task :rebuild do - Rake::Task['db:drop'].invoke - Rake::Task['db:drop_integration'].invoke - Rake::Task['db:create'].invoke - Rake::Task['db:migrate'].invoke - puts "seeding users, this will take awhile" - `rake db:seed` #ghetto hax as we have active record garbage in our models - puts "seeded!" - Rake::Task['db:test:prepare'].invoke - end - - namespace :integration do - # desc 'Check for pending migrations and load the integration schema' - task :prepare => :environment do - abcs = ActiveRecord::Base.configurations - envs = abcs.keys.select{ |k| k.include?("integration") } - puts envs.inspect - envs.each_with_index do |env, i| - Rails.env = env - Rake::Task.tasks.each{ |task| task.reenable } - - print "\n\n## preparing database for #{env}... " - puts (i == 0) ? "(go get yourself a coffee)" : "(time for another coffee)" - - # do drop, schema:load_if_ruby, structure:load_if_sql, seed - Rake::Task['db:drop'].invoke - Rake::Task['db:setup'].invoke - - puts "db #{ActiveRecord::Base.connection.current_database} done" - end - end - end - - desc 'Delete the collections in the current RAILS_ENV database' + desc "Reset the current RAILS_ENV database and delete the upload-folder" task :purge do - require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment') + require File.join(File.dirname(__FILE__), "..", "..", "config", "environment") puts "Purging the database for #{Rails.env}..." - Rake::Task['db:rebuild'].invoke - - puts 'Deleting tmp folder...' - `rm -rf #{File.dirname(__FILE__)}/../../public/uploads/*` - end - - desc 'Purge and seed the current RAILS_ENV database using information from db/seeds.rb' - task :reset do - puts "Resetting the database for #{Rails.env}".upcase - Rake::Task['db:purge'].invoke - Rake::Task['db:seed'].invoke - puts "Success!" - end - - task :drop_integration do - ActiveRecord::Base.configurations.keys.select{ |k| - k.include?("integration") - }.each{ |k| - drop_database ActiveRecord::Base.configurations[k] rescue Mysql2::Error - } - end - - task :fix_diaspora_handle do - puts "fixing the people in this seed" - require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment') - Person.where(:url => 'example.org').all.each{|person| - if person.owner - person.url = AppConfig.pod_uri.to_s - person.diaspora_handle = person.owner.diaspora_handle - person.save - end - } - puts "everything should be peachy" - end + Rake::Task["db:reset"].invoke - task :move_private_key do - require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment') - User.all.each do |user| - if user.serialized_private_key.nil? - user.serialized_private_key = user.person.serialized_key - user.save - person = user.person - person.serialized_key = nil - person.serialized_public_key = user.encryption_key.public_key.to_s - person.save - end - end + puts "Deleting tmp folder..." + `rm -rf #{File.dirname(__FILE__)}/../../public/uploads/*` end end diff --git a/lib/tasks/maintenance.rake b/lib/tasks/maintenance.rake index 746a773f5c4b25e739130061f067bbdea4c79ba3..042d78b58638ff8be79f9b232787d66a2a16444b 100644 --- a/lib/tasks/maintenance.rake +++ b/lib/tasks/maintenance.rake @@ -3,40 +3,6 @@ # the COPYRIGHT file. namespace :maintenance do - APP_ROOT = File.expand_path( File.join( File.dirname( __FILE__ ), '..', '..') ) - desc "Clear CarrierWave temp uploads" - task :clear_carrierwave_temp_uploads do - filename = File.join( APP_ROOT, 'tmp', 'uploads', '*') - today_string = Time.now.strftime( '%Y%m%d' ) - Dir.glob( filename ) do |file| - unless file.include?( today_string ) - FileUtils.rm_rf( file ) - end - end - end - - desc "Rotate Diaspora logs" - task :install_logrotate_config do - logrotate_conf = <<-RUBY -#{APP_ROOT}/logs/production.log { - daily - missingok - rotate 8 - compress - delaycompress - notifempty - copytruncate -} -RUBY - begin - File.open('/etc/logrotate.d/diaspora') do |fin| - fin.write logrotate_conf - end - rescue - puts "Could not install logrotate configs. Perhaps you should try running this task as root and ensuring logrotate is installed:\n#{logrotate_conf}" - end - end - desc "Queue users for removal" task :queue_users_for_removal => :environment do # Queue users for removal due to inactivity diff --git a/lib/tasks/migrations.rake b/lib/tasks/migrations.rake index 0ad1291d402ddd467621389d31a109adec3b6e57..45703ed5694d14f077901d8ad047e29685775ee3 100644 --- a/lib/tasks/migrations.rake +++ b/lib/tasks/migrations.rake @@ -3,50 +3,6 @@ # the COPYRIGHT file. namespace :migrations do - - desc 'copy all hidden share visibilities from share_visibilities to users. Can be run with the site still up.' - task :copy_hidden_share_visibilities_to_users => [:environment] do - require Rails.root.join('lib', 'share_visibility_converter') - ShareVisibilityConverter.copy_hidden_share_visibilities_to_users - end - - desc 'puts out information about old invited users' - task :invitations => [:environment] do - puts "email, invitation_token, :invited_by_id, :invitation_identifier" - User.where('username is NULL').select([:id, :email, :invitation_token, :invited_by_id, :invitation_identifier]).find_in_batches do |users| - users.each{|x| puts "#{x.email}, #{x.invitation_token}, #{x.invited_by_id}, #{x.invitation_identifier}" } - end - puts "done" - end - - desc 'absolutify all existing image references' - task :absolutify_image_references do - require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment') - - Photo.all.each do |photo| - unless photo.remote_photo_path - # extract root - # - pod = URI::parse(photo.person.url) - pod_url = "#{pod.scheme}://#{pod.host}" - - if photo.image.url - remote_path = "#{photo.image.url}" - else - puts pod_url - remote_path = "#{pod_url}#{photo.remote_photo_path}/#{photo.remote_photo_name}" - end - - # get path/filename - name_start = remote_path.rindex '/' - photo.remote_photo_path = "#{remote_path.slice(0, name_start)}/" - photo.remote_photo_name = remote_path.slice(name_start + 1, remote_path.length) - - photo.save! - end - end - end - task :upload_photos_to_s3 do require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment') puts AppConfig.environment.s3.key @@ -72,60 +28,6 @@ namespace :migrations do end end } - - end - - # removes hashtags with uppercase letters and re-attaches - # the posts to the lowercase version - task :rewire_uppercase_hashtags => :environment do - evil_tags = ActsAsTaggableOn::Tag.where("lower(name) != name") - puts "found #{evil_tags.count} tags to convert..." - - evil_tags.each_with_index do |tag, i| - good_tag = ActsAsTaggableOn::Tag.first_or_create_by(name: tag.name.mb_chars.downcase) - puts "++ '#{tag.name}' has #{tag.taggings.count} records attached" - - taggings = tag.taggings - deleteme = [] - - taggings.each do |tagging| - if good_tag.taggings.where(:taggable_id => tagging.taggable_id).count > 0 - # the same taggable is already tagged with the correct tag - # just delete the obsolete tagging it - deleteme << tagging - next - end - - # the tagging exists only for the wrong tag, move it to the 'good tag' - good_tag.taggings << tagging - end - - deleteme.each do |tagging| - tagging.destroy - end - - rest = tag.taggings(true) # force reload - if rest.count > 0 - puts "-- the tag #{tag.name} still has some taggings - aborting!" - break - end - - # no more taggings left, delete the tag - tag.destroy - - puts "-- converted '#{tag.name}' to '#{good_tag.name}'" - puts "\n## #{i+1} tags processed\n\n" if ((i+1) % 50 == 0) - end - end - - task :remove_uppercase_hashtags => :environment do - evil_tags = ActsAsTaggableOn::Tag.where("lower(name) != name") - evil_tags.each do |tag| - next if tag.taggings.count > 0 # non-ascii tags - - puts "removing '#{tag.name}'..." - tag.destroy - end end CURRENT_QUEUES = %w(urgent high medium low default).freeze