Moved to use current user model, also if attributes has changed.
This commit is contained in:
parent
9123533f1b
commit
9950ede40a
2 changed files with 7 additions and 11 deletions
|
@ -58,8 +58,6 @@ class Sessions::Client
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# verify already pushed data, send update if needed
|
# verify already pushed data, send update if needed
|
||||||
if !Sessions::CacheIn.get( 'pushed_tickets' + @client_id.to_s )
|
if !Sessions::CacheIn.get( 'pushed_tickets' + @client_id.to_s )
|
||||||
Sessions::CacheIn.set( 'pushed_tickets' + @client_id.to_s , true, { :expires_in => 60.seconds } )
|
Sessions::CacheIn.set( 'pushed_tickets' + @client_id.to_s , true, { :expires_in => 60.seconds } )
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
class Sessions::Worker
|
class Sessions::Worker
|
||||||
def initialize( user_id )
|
def initialize( user_id )
|
||||||
@user_id = user_id
|
@user_id = user_id
|
||||||
@data = {}
|
|
||||||
@cache_key = 'user_' + user_id.to_s
|
|
||||||
self.log 'notify', "---user started user state"
|
self.log 'notify', "---user started user state"
|
||||||
|
|
||||||
Sessions::CacheIn.set( 'last_run_' + user_id.to_s , true, { :expires_in => 20.seconds } )
|
Sessions::CacheIn.set( 'last_run_' + user_id.to_s , true, { :expires_in => 20.seconds } )
|
||||||
|
|
||||||
user = User.find( @user_id )
|
self.fetch( user_id )
|
||||||
return if !user
|
|
||||||
|
|
||||||
self.fetch( user )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch(user)
|
def fetch(user_id)
|
||||||
|
|
||||||
while true
|
while true
|
||||||
|
user = User.lookup( :id => user_id )
|
||||||
|
return if !user
|
||||||
|
|
||||||
# check if user is still with min one open connection
|
# check if user is still with min one open connection
|
||||||
if !Sessions::CacheIn.get( 'last_run_' + user.id.to_s )
|
if !Sessions::CacheIn.get( 'last_run_' + user.id.to_s )
|
||||||
|
@ -24,6 +22,7 @@ class Sessions::Worker
|
||||||
end
|
end
|
||||||
|
|
||||||
self.log 'notice', "---user - fetch user data"
|
self.log 'notice', "---user - fetch user data"
|
||||||
|
|
||||||
# overview
|
# overview
|
||||||
Sessions::Backend::TicketOverviewIndex.worker( user, self )
|
Sessions::Backend::TicketOverviewIndex.worker( user, self )
|
||||||
|
|
||||||
|
@ -54,5 +53,4 @@ class Sessions::Worker
|
||||||
return if level == 'notice'
|
return if level == 'notice'
|
||||||
puts "#{Time.now}:user_id(#{ @user_id }) #{ data }"
|
puts "#{Time.now}:user_id(#{ @user_id }) #{ data }"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue