Files
danbooru/app/jobs/application_job.rb
evazion 1d2bac7b95 Remove CurrentUser.ip_addr.
Remove the `CurrentUser.ip_addr` global variable and replace it with
`request.remote_ip`. Before we had to track the current user's IP in a
global variable so that when we edited a post for example, we could pass
down the user's IP to the model and save it in the post_versions table.
Now that we now longer save IPs in version tables, we don't need a global
variable to get access to the current user's IP outside of controllers.
2022-09-18 05:02:10 -05:00

41 lines
1.3 KiB
Ruby

# frozen_string_literal: true
# The base class for all background jobs on Danbooru.
#
# @see https://guides.rubyonrails.org/active_job_basics.html
# @see https://github.com/bensheldon/good_job
class ApplicationJob < ActiveJob::Base
class JobTimeoutError < StandardError; end
queue_as :default
queue_with_priority 0
around_perform do |_job, block|
CurrentUser.scoped(User.system) do
ApplicationRecord.without_timeout do
Timeout.timeout(24.hours, JobTimeoutError) do
block.call
end
end
end
end
discard_on ActiveJob::DeserializationError do |_job, error|
DanbooruLogger.log(error)
end
# A list of all available job types. Used by the /jobs search form.
def self.job_classes
[
AmcheckDatabaseJob, BigqueryExportAllJob, DeleteFavoritesJob,
DmailInactiveApproversJob, IqdbAddPostJob, IqdbRemovePostJob,
PopulateSavedSearchJob, PruneApproversJob, PruneBansJob,
PruneBulkUpdateRequestsJob, PrunePostDisapprovalsJob, PrunePostsJob,
PruneRateLimitsJob, ProcessUploadJob, RegeneratePostCountsJob,
RegeneratePostJob, RetireTagRelationshipsJob, VacuumDatabaseJob,
DiscordNotificationJob, BigqueryExportJob, ProcessBulkUpdateRequestJob,
PruneJobsJob, ActionMailer::MailDeliveryJob
]
end
end