From 9950ede40a8c634178b3f39135378be64092bf26 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 1 Oct 2013 20:34:45 +0200 Subject: [PATCH] Moved to use current user model, also if attributes has changed. --- lib/sessions/client.rb | 2 -- lib/sessions/worker.rb | 16 +++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/sessions/client.rb b/lib/sessions/client.rb index 6c7f24af2..c4f0cdab9 100644 --- a/lib/sessions/client.rb +++ b/lib/sessions/client.rb @@ -58,8 +58,6 @@ class Sessions::Client end end - - # verify already pushed data, send update if needed if !Sessions::CacheIn.get( 'pushed_tickets' + @client_id.to_s ) Sessions::CacheIn.set( 'pushed_tickets' + @client_id.to_s , true, { :expires_in => 60.seconds } ) diff --git a/lib/sessions/worker.rb b/lib/sessions/worker.rb index 9eea1840f..a8cb81042 100644 --- a/lib/sessions/worker.rb +++ b/lib/sessions/worker.rb @@ -1,21 +1,19 @@ class Sessions::Worker def initialize( user_id ) @user_id = user_id - @data = {} - @cache_key = 'user_' + user_id.to_s + self.log 'notify', "---user started user state" Sessions::CacheIn.set( 'last_run_' + user_id.to_s , true, { :expires_in => 20.seconds } ) - user = User.find( @user_id ) - return if !user - - self.fetch( user ) + self.fetch( user_id ) end - def fetch(user) + def fetch(user_id) while true + user = User.lookup( :id => user_id ) + return if !user # check if user is still with min one open connection if !Sessions::CacheIn.get( 'last_run_' + user.id.to_s ) @@ -24,6 +22,7 @@ class Sessions::Worker end self.log 'notice', "---user - fetch user data" + # overview Sessions::Backend::TicketOverviewIndex.worker( user, self ) @@ -54,5 +53,4 @@ class Sessions::Worker return if level == 'notice' puts "#{Time.now}:user_id(#{ @user_id }) #{ data }" end -end - +end \ No newline at end of file