mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added a separate table to record background job status for tournaments and fixed migrations/schemas for solid dbs. Foreign key constraints are now added to the migrations where we do belongs_to.
This commit is contained in:
@@ -15,52 +15,3 @@ else
|
||||
# In test, use inline adapter for simplicity
|
||||
Rails.application.config.active_job.queue_adapter = :inline
|
||||
end
|
||||
|
||||
# Register the custom attributes we want to track
|
||||
module SolidQueueConfig
|
||||
mattr_accessor :job_owner_tracking_enabled, default: true
|
||||
end
|
||||
|
||||
# Define ActiveJobExtensions - this should match what's already being used in ApplicationJob
|
||||
module ActiveJobExtensions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_accessor :job_owner_id, :job_owner_type
|
||||
end
|
||||
end
|
||||
|
||||
# Solid Queue adapter hooks to save job owner info to columns
|
||||
module SolidQueueAdapterExtensions
|
||||
def enqueue(job)
|
||||
job_data = job.serialize
|
||||
job_id = super
|
||||
|
||||
# Store job owner info after job is created
|
||||
if defined?(SolidQueue::Job) && job_data["job_owner_id"].present?
|
||||
Rails.logger.info("Setting job_owner for SolidQueue job #{job_id}: #{job_data["job_owner_id"]}, #{job_data["job_owner_type"]}")
|
||||
begin
|
||||
# Use execute_query for direct SQL to bypass any potential ActiveRecord issues
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE solid_queue_jobs SET job_owner_id = #{ActiveRecord::Base.connection.quote(job_data["job_owner_id"])}, " +
|
||||
"job_owner_type = #{ActiveRecord::Base.connection.quote(job_data["job_owner_type"])} " +
|
||||
"WHERE id = #{job_id}"
|
||||
)
|
||||
Rails.logger.info("Successfully updated job_owner info for job #{job_id}")
|
||||
rescue => e
|
||||
Rails.logger.error("Error updating job_owner info: #{e.message}")
|
||||
end
|
||||
end
|
||||
|
||||
job_id
|
||||
end
|
||||
end
|
||||
|
||||
# Apply extensions
|
||||
Rails.application.config.after_initialize do
|
||||
# Add extensions to ActiveJob::QueueAdapters::SolidQueueAdapter if defined
|
||||
if defined?(ActiveJob::QueueAdapters::SolidQueueAdapter)
|
||||
Rails.logger.info("Applying SolidQueueAdapterExtensions")
|
||||
ActiveJob::QueueAdapters::SolidQueueAdapter.prepend(SolidQueueAdapterExtensions)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user