Skip to content

Commit

Permalink
Avoid forcing applications to have a root ApplicationJob defined
Browse files Browse the repository at this point in the history
Also remove unused MissionControl::Jobs::ApplicationJob
  • Loading branch information
alxckn authored and rosa committed Feb 22, 2024
1 parent c14ab26 commit 609c895
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module MissionControl::Jobs::FailedJobsBulkOperations
# or causing replication lag in MySQL). This should be enough for most scenarios. For
# cases where we need to retry a huge sets of jobs, we offer a runbook that uses the API.
def bulk_limited_filtered_failed_jobs
ApplicationJob.jobs.failed.where(**@job_filters).limit(MAX_NUMBER_OF_JOBS_FOR_BULK_OPERATIONS)
ActiveJob::Base.jobs.failed.where(**@job_filters).limit(MAX_NUMBER_OF_JOBS_FOR_BULK_OPERATIONS)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def jobs_to_discard
bulk_limited_filtered_failed_jobs
else
# we don't want to apply any limit since "discarding all" without parameters can be optimized in the adapter as a much faster operation
ApplicationJob.jobs.failed
ActiveJob::Base.jobs.failed
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def create

private
def jobs_relation
ApplicationJob.jobs.failed
ActiveJob::Base.jobs.failed
end
end
6 changes: 3 additions & 3 deletions app/controllers/mission_control/jobs/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MissionControl::Jobs::JobsController < MissionControl::Jobs::ApplicationCo

def index
@job_class_names = jobs_with_status.job_class_names
@queue_names = ApplicationJob.queues.map(&:name)
@queue_names = ActiveJob::Base.queues.map(&:name)

@jobs_page = MissionControl::Jobs::Page.new(filtered_jobs_with_status, page: params[:page].to_i)
@jobs_count = @jobs_page.total_count
Expand All @@ -24,11 +24,11 @@ def filtered_jobs_with_status
end

def jobs_with_status
ApplicationJob.jobs.with_status(jobs_status)
ActiveJob::Base.jobs.with_status(jobs_status)
end

def filtered_jobs
ApplicationJob.jobs.where(**@job_filters)
ActiveJob::Base.jobs.where(**@job_filters)
end

helper_method :jobs_status
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/mission_control/jobs/queues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ def show

private
def set_queue
@queue = ApplicationJob.queues[params[:id]]
@queue = ActiveJob::Base.queues[params[:id]]
end

def filtered_queues
if prefix = ApplicationJob.queue_name_prefix
ApplicationJob.queues.select { |queue| queue.name.start_with?(prefix) }
if prefix = ActiveJob::Base.queue_name_prefix
ActiveJob::Base.queues.select { |queue| queue.name.start_with?(prefix) }
else
ApplicationJob.queues
ActiveJob::Base.queues
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/mission_control/jobs/retries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def create

private
def jobs_relation
ApplicationJob.jobs.failed
ActiveJob::Base.jobs.failed
end
end
2 changes: 1 addition & 1 deletion app/helpers/mission_control/jobs/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def jobs_filter_param
end

def jobs_count_with_status(status)
count = ApplicationJob.jobs.with_status(status).count
count = ActiveJob::Base.jobs.with_status(status).count
count.infinite? ? "..." : number_to_human(count)
end
end
6 changes: 0 additions & 6 deletions app/jobs/mission_control/jobs/application_job.rb

This file was deleted.

0 comments on commit 609c895

Please sign in to comment.