Guest User

Untitled

a guest
May 23rd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. namespace :maintain do
  2.  
  3. STALE_SESSION_DEADLINE = 2.days.ago
  4. STALE_PHANTOM_JOB_DEADLINE = 1.day.ago
  5.  
  6. desc "Run all database maintainance tasks"
  7. task :maintain_database => :environment do
  8. Rake::Task['fintrans:maintain:remove_stale_phantoms'].invoke
  9. Rake::Task['fintrans:maintain:remove_stale_sessions'].invoke
  10. end
  11.  
  12. desc "Remove stale phantoms"
  13. task :remove_stale_phantoms => :environment do
  14. Time.zone = "Bern"
  15. CGI::Session::ActiveRecordStore::Jobs.destroy_all( ['customer_id=NULL && updated_at<?', STALE_PHANTOM_JOB_DEADLINE] )
  16. end
  17.  
  18. desc "Remove stale sessions"
  19. task :remove_stale_sessions => :environment do
  20. Time.zone = "Bern"
  21. CGI::Session::ActiveRecordStore::Session.destroy_all( ['updated_at<?', STALE_SESSION_DEADLINE] )
  22. end
  23.  
  24. end
Add Comment
Please, Sign In to add comment