mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 04:35:26 +00:00
Upgraded to rails 8.0.2, moved from dalli to solid cache, moved from delayed_job to solid queue, and add solid cable. deploy/rails-dev-run.sh no longer needs to chmod. Fixed finished_at callback for matches. Migrated from Devise to built in rails auth. Added view tests for the bracket page testing that all bout numbers render for all matches in each bracket type.
This commit is contained in:
66
config/initializers/solid_queue.rb
Normal file
66
config/initializers/solid_queue.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
# Configuration for Solid Queue in Rails 8
|
||||
# Documentation: https://github.com/rails/solid_queue
|
||||
|
||||
# Configure ActiveJob queue adapter based on environment
|
||||
if ! Rails.env.test?
|
||||
# In production and development, use solid_queue with async execution
|
||||
Rails.application.config.active_job.queue_adapter = :solid_queue
|
||||
|
||||
# Configure for regular async processing
|
||||
Rails.application.config.active_job.queue_adapter_options = {
|
||||
execution_mode: :async,
|
||||
logger: Rails.logger
|
||||
}
|
||||
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