From 7596b6dbfa38d52acd447982e03e26374fb0d747 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 21 Nov 2013 12:49:25 +0100 Subject: rake tasks clean up expired tokens and sessions (#4568) --- core/leap_web_core.gemspec | 2 +- core/lib/tasks/leap_web_core_tasks.rake | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/leap_web_core.gemspec b/core/leap_web_core.gemspec index e98c892..c745f00 100644 --- a/core/leap_web_core.gemspec +++ b/core/leap_web_core.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.add_dependency "couchrest", "~> 1.1.3" s.add_dependency "couchrest_model", "~> 2.0.0" - s.add_dependency "couchrest_session_store", "~> 0.2.0" + s.add_dependency "couchrest_session_store", "~> 0.2.1" s.add_dependency "json" end diff --git a/core/lib/tasks/leap_web_core_tasks.rake b/core/lib/tasks/leap_web_core_tasks.rake index 734fae9..ec6abac 100644 --- a/core/lib/tasks/leap_web_core_tasks.rake +++ b/core/lib/tasks/leap_web_core_tasks.rake @@ -7,3 +7,19 @@ namespace :couchrest do end end +namespace :cleanup do + + desc "Cleanup all expired session documents" + task :sessions => :environment do + # make sure this is the same as in + # config/initializers/session_store.rb + store = CouchRest::Session::Store.new expire_after: 1800 + store.cleanup(store.expired) + end + + desc "Cleanup all expired tokens" + task :tokens => :environment do + Token.destroy_all_expired + end +end + -- cgit v1.2.3