* remove crazy debugging from base manager
This commit is contained in:
parent
c9c384cbf0
commit
a6c054635d
|
|
@ -4,7 +4,11 @@ module JamRuby
|
||||||
attr_accessor :pg_conn
|
attr_accessor :pg_conn
|
||||||
|
|
||||||
@@log = Logging.logger[BaseManager]
|
@@log = Logging.logger[BaseManager]
|
||||||
@@in_websocket_gateway = Rails.env != 'test' && !Object.const_defined?(:UserManager)
|
|
||||||
|
# this is not working as expected
|
||||||
|
#@@in_websocket_gateway = Rails.env != 'test' && !Object.const_defined?(:UserManager)
|
||||||
|
|
||||||
|
@@in_websocket_gateway = false
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
@log = Logging.logger[self]
|
@log = Logging.logger[self]
|
||||||
|
|
@ -19,12 +23,10 @@ module JamRuby
|
||||||
def self.active_record_transaction
|
def self.active_record_transaction
|
||||||
|
|
||||||
manager = self.new
|
manager = self.new
|
||||||
@@log.error "DEBUG_TRAN S"
|
|
||||||
ActiveRecord::Base.connection_pool.with_connection do |connection|
|
ActiveRecord::Base.connection_pool.with_connection do |connection|
|
||||||
# create a transaction, and pass the current connection to ConnectionManager.
|
# create a transaction, and pass the current connection to ConnectionManager.
|
||||||
# this lets the entire operation work with the same transaction,
|
# this lets the entire operation work with the same transaction,
|
||||||
# across Rails ActiveRecord and the pg-gem based code in ConnectionManager.
|
# across Rails ActiveRecord and the pg-gem based code in ConnectionManager.
|
||||||
@@log.error "DEBUG_TRAN -1"
|
|
||||||
manager.pg_conn = connection.instance_variable_get("@connection")
|
manager.pg_conn = connection.instance_variable_get("@connection")
|
||||||
|
|
||||||
if @@in_websocket_gateway
|
if @@in_websocket_gateway
|
||||||
|
|
@ -37,9 +39,7 @@ module JamRuby
|
||||||
ActiveRecord::Base.connection.execute('ROLLBACK')
|
ActiveRecord::Base.connection.execute('ROLLBACK')
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@log.error "DEBUG_TRAN -2"
|
|
||||||
connection.transaction do
|
connection.transaction do
|
||||||
@@log.error "DEBUG_TRAN -3"
|
|
||||||
yield manager
|
yield manager
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -405,17 +405,12 @@ SQL
|
||||||
def join_music_session(user, client_id, music_session, as_musician, tracks, audio_latency, video_sources=nil)
|
def join_music_session(user, client_id, music_session, as_musician, tracks, audio_latency, video_sources=nil)
|
||||||
connection = nil
|
connection = nil
|
||||||
|
|
||||||
@log.error "DEBUG_TRAN 1"
|
|
||||||
ConnectionManager.active_record_transaction do |connection_manager|
|
ConnectionManager.active_record_transaction do |connection_manager|
|
||||||
@log.error "DEBUG_TRAN 2"
|
|
||||||
db_conn = connection_manager.pg_conn
|
db_conn = connection_manager.pg_conn
|
||||||
@log.error "DEBUG_TRAN 3"
|
|
||||||
|
|
||||||
connection = Connection.find_by_client_id_and_user_id!(client_id, user.id)
|
connection = Connection.find_by_client_id_and_user_id!(client_id, user.id)
|
||||||
@log.error "DEBUG_TRAN 4"
|
|
||||||
|
|
||||||
connection.join_the_session(music_session, as_musician, tracks, user, audio_latency, video_sources)
|
connection.join_the_session(music_session, as_musician, tracks, user, audio_latency, video_sources)
|
||||||
@log.error "DEBUG_TRAN 5"
|
|
||||||
JamRuby::MusicSessionUserHistory.join_music_session(user.id, music_session.id)
|
JamRuby::MusicSessionUserHistory.join_music_session(user.id, music_session.id)
|
||||||
# connection.music_session_id = music_session.id
|
# connection.music_session_id = music_session.id
|
||||||
# connection.as_musician = as_musician
|
# connection.as_musician = as_musician
|
||||||
|
|
@ -423,19 +418,15 @@ SQL
|
||||||
# connection.joined_session_at = Time.now
|
# connection.joined_session_at = Time.now
|
||||||
# associate_tracks(connection, tracks)
|
# associate_tracks(connection, tracks)
|
||||||
# connection.save
|
# connection.save
|
||||||
@log.error "DEBUG_TRAN 6"
|
|
||||||
|
|
||||||
if connection.errors.any?
|
if connection.errors.any?
|
||||||
@log.error "DEBUG_TRAN 7"
|
|
||||||
raise ActiveRecord::Rollback
|
raise ActiveRecord::Rollback
|
||||||
else
|
else
|
||||||
@log.error "DEBUG_TRAN 8"
|
|
||||||
update_session_controller(music_session.id)
|
update_session_controller(music_session.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@log.error "DEBUG_TRAN 9"
|
|
||||||
connection
|
connection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue