Sha256: f912273162ba9c03b20e428a2609d49b9b20343b394781c2dbec5605d4a2a99a
Contents?: true
Size: 1.48 KB
Versions: 15
Compression:
Stored size: 1.48 KB
Contents
# This effectively hides the rake task from `$ rake -T`. Rake::Task["jobshop:install:migrations"].instance_variable_set(:@comments, []) namespace :jobshop do task :disable_autoload do ActiveSupport::Dependencies.class_eval do extend Module.new { def load_file(path, const_paths = loadable_constants_for_path(path)) jobshop_models_path = File.join(Jobshop::Engine.root, "app", "models") return if path.starts_with?(jobshop_models_path) super end } end end desc "Outputs team[:name] and team[:id] for all sites within Jobshop." task teams: :environment do Jobshop::Team.joins(:owner) .select([ "jobshop_teams.id", "name", "jobshop_users.email AS owner_email" ]).each do |team| team_name = team.name.ljust(32) puts "#{team_name} | #{team.id} | #{team.owner_email} " end end namespace :teams do desc "Clear out teams that haven't been registered after 24 hours" task purge: :environment do deleted_teams = Jobshop::Team .where(Jobshop::Team.arel_table[:registration_token_sent_at] .lt(24.hours.ago)) .where(owner_id: nil) .destroy_all count = deleted_teams.count inflection = "team".pluralize(count) list = deleted_teams.map(&:id).join("\n") puts "Purged #{count} #{inflection}\n#{list}" end end end %w( db:migrate db:rollback db:migrate:up db:migrate:down ).each do |t| Rake::Task[t].prerequisites << "jobshop:disable_autoload" end
Version data entries
15 entries across 15 versions & 1 rubygems