diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2015-05-19 12:14:59 +0200 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2015-05-22 13:20:24 +0200 |
commit | 7064594f5163c79a7596761afe93c9a94c91656b (patch) | |
tree | 4e64fb9d8c8a6ce507acc83e67644662b167a32f | |
parent | 8f2e7ada4784efe273a59b654425c0be89cfd371 (diff) | |
download | ecs2-7064594f5163c79a7596761afe93c9a94c91656b.tar.gz ecs2-7064594f5163c79a7596761afe93c9a94c91656b.zip |
New rake task ecs:gc_sub_participants.
Default ttl value for subparticipants being deleted is 10 days. Please
adjust to your needs directly in the source task file.
-rw-r--r-- | lib/tasks/ecs_garbage_collect_sub_participants.rake | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/tasks/ecs_garbage_collect_sub_participants.rake b/lib/tasks/ecs_garbage_collect_sub_participants.rake new file mode 100644 index 0000000..eba5971 --- /dev/null +++ b/lib/tasks/ecs_garbage_collect_sub_participants.rake @@ -0,0 +1,16 @@ +namespace :ecs do + desc "Delete outtimed subparticipants." + task :gc_sub_participants => :environment do + ttl= 10.days.ago + num= 0 + Participant.only_subparticipants.each do |p| + if p.created_at <= ttl + p.destroy + num+=1 + end + end + txt= "Number of deleted subparticipants: #{num}" + puts txt + RAILS_DEFAULT_LOGGER.info txt + end +end |