Files
danbooru/app/logical/danbooru_maintenance.rb
evazion 13528ac2d3 Drop forum subscriptions.
Few people used forum subscriptions (only around 100), and even fewer
people were subscribed to active threads. Most subscriptions were for
old threads that will never be bumped again. The implementation also had
a few problems:

* Unsubscribe links in emails didn't work (they unset the user's
  receive_email_notifications flag, but forum subscriptions didn't
  respect this flag).
* Some users had invalid email addresses, which caused notifications to
  bounce. There was no mechanism for preventing bounces.
* The implementation wasn't scalable. It involved a daily linear scan
  over _all_ forum subscriptions looking for any topics that had been updated.
2020-01-21 00:10:21 -06:00

46 lines
1.2 KiB
Ruby

module DanbooruMaintenance
module_function
def hourly
end
def daily
safely { PostPruner.new.prune! }
safely { Upload.prune! }
safely { Delayed::Job.where('created_at < ?', 45.days.ago).delete_all }
safely { PostDisapproval.prune! }
safely { PostDisapproval.dmail_messages! }
safely { regenerate_post_counts! }
safely { SuperVoter.init! }
safely { TokenBucket.prune! }
safely { TagChangeRequestPruner.warn_all }
safely { TagChangeRequestPruner.reject_all }
safely { Ban.prune! }
safely { CuratedPoolUpdater.update_pool! }
safely { ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test? }
end
def weekly
safely { UserPasswordResetNonce.prune! }
safely { TagRelationshipRetirementService.find_and_retire! }
end
def monthly
safely { ApproverPruner.prune! }
end
def regenerate_post_counts!
updated_tags = Tag.regenerate_post_counts!
updated_tags.each do |tag|
DanbooruLogger.info("Updated tag count", tag.attributes)
end
end
def safely(&block)
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
yield
rescue StandardError => exception
DanbooruLogger.log(exception)
end
end