eBooru/app/logical/maintenance.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

27 lines
946 B
Ruby

# frozen_string_literal: true
module Maintenance
module_function
def daily
ignoring_exceptions { PostPruner.new.prune! }
ignoring_exceptions { Upload.where('created_at < ?', 1.week.ago).delete_all }
ignoring_exceptions { ForumSubscription.process_all! }
ignoring_exceptions { TagAlias.update_cached_post_counts_for_all }
ignoring_exceptions { Tag.clean_up_negative_post_counts! }
ignoring_exceptions { Ban.prune! }
ignoring_exceptions { UserPasswordResetNonce.prune! }
ignoring_exceptions { StatsUpdater.run! }
ignoring_exceptions { DiscordReport::JanitorStats.new.run! }
ignoring_exceptions { DiscordReport::ModeratorStats.new.run! }
ignoring_exceptions { DiscordReport::AiburStats.new.run! }
end
def ignoring_exceptions(&block)
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
yield
rescue StandardError => exception
DanbooruLogger.log(exception)
end
end