aboutsummaryrefslogtreecommitdiff
path: root/lib/tasks/ecs_garbage_collect_sub_participants.rake
blob: b20c50b34a177907ac22a58f415530073ae4ac06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
namespace :ecs do
  desc "Delete outtimed subparticipants."
  task :gc_sub_participants => :environment  do
    ttl= 2.days.ago
    num= 0
    Participant.only_subparticipants.each do |p|
      if p.created_at <= ttl
        p.destroy
        num+=1
      end
    end
    txt= "gc_sub_participants: Number of deleted subparticipants: #{num}"
    puts txt
    RAILS_DEFAULT_LOGGER.info txt
  end
end