修訂 | 7e2cac11847ac296f80ab0e012a4e9718bbf91bf (tree) |
---|---|
時間 | 2020-08-31 04:38:49 |
作者 | HMML <hmml3939@gmai...> |
Commiter | HMML |
Change cleanup job structure, add feed cleaner.
@@ -0,0 +1,20 @@ | ||
1 | +namespace :cleanup do | |
2 | + desc "Cleanup old dist signals" | |
3 | + task signals: :environment do | |
4 | + count = DistSignal.where(status: %i(completed failed ignored)). | |
5 | + where("created_at < ?", 1.week.ago).delete_all | |
6 | + Rails.logger.info "Remove old #{count} dist signals" | |
7 | + end | |
8 | + | |
9 | + desc "Cleanup expired drafts" | |
10 | + task drafts: :environment do | |
11 | + count = Draft.where("expires_at < ?", Time.now).delete_all | |
12 | + Rails.logger.info "Remove expired #{count} drafts" | |
13 | + end | |
14 | + | |
15 | + desc "Cleanup old feed" | |
16 | + task jma_feeds: :environment do | |
17 | + count = JmaFeed.where("feed_time < ?", 2.days.ago).delete_all | |
18 | + Rails.logger.info "Remove expired #{count} drafts" | |
19 | + end | |
20 | +end |
@@ -1,10 +0,0 @@ | ||
1 | -namespace :dist_signals do | |
2 | - desc "Cleanup old dist signals" | |
3 | - task cleanup: :environment do | |
4 | - DistSignal.transaction do | |
5 | - count = DistSignal.where(status: %i(completed failed ignored)). | |
6 | - where("created_at < ?", 1.week.ago).delete_all | |
7 | - Rails.logger.info "Remove old #{count} dist signals" | |
8 | - end | |
9 | - end | |
10 | -end |
@@ -1,9 +0,0 @@ | ||
1 | -namespace :drafts do | |
2 | - desc "Cleanup expired drafts" | |
3 | - task cleanup: :environment do | |
4 | - Draft.transaction do | |
5 | - count = Draft.where("expires_at < ?", Time.now).delete_all | |
6 | - Rails.logger.info "Remove expired #{count} drafts" | |
7 | - end | |
8 | - end | |
9 | -end |