Files
danbooru/app/jobs/application_job.rb
evazion 82211ba935 jobs: add ability to search jobs on /jobs page.
Add ability to search jobs on the /jobs page by job type or by status.

Fixes #2577 (Search filters for delayed jobs). This wasn't possible
before with DelayedJobs because it stored the job data in a YAML string,
which made it difficult to search jobs by type. GoodJobs stores job data
in a JSON object, which is easier to search in Postgres.
2022-01-04 17:18:36 -06:00

42 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, "127.0.0.1") do
ApplicationRecord.without_timeout do
Timeout.timeout(8.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, PruneUploadsJob, RegeneratePostCountsJob,
RegeneratePostJob, RetireTagRelationshipsJob,
UploadPreprocessorDelayedStartJob, UploadServiceDelayedStartJob,
VacuumDatabaseJob, DiscordNotificationJob, BigqueryExportJob,
ProcessBulkUpdateRequestJob, PruneJobsJob
]
end
end