Fixed last_change feature.
This commit is contained in:
parent
683d676565
commit
33fe217401
8 changed files with 22 additions and 24 deletions
|
@ -1,5 +1,4 @@
|
|||
module Sessions::Backend::ActivityStream
|
||||
@@last_change = {}
|
||||
|
||||
def self.worker( user, worker )
|
||||
cache_key = 'user_' + user.id.to_s + '_activity_stream'
|
||||
|
@ -21,8 +20,8 @@ module Sessions::Backend::ActivityStream
|
|||
cache_key = 'user_' + user.id.to_s + '_activity_stream'
|
||||
|
||||
activity_stream_time = Sessions::CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if activity_stream_time && @@last_change[ user.id ] != activity_stream_time
|
||||
@@last_change[ user.id ] = activity_stream_time
|
||||
if activity_stream_time && client.last_change['activity_stream'] != activity_stream_time
|
||||
client.last_change['activity_stream'] = activity_stream_time
|
||||
activity_stream = Sessions::CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
client.log 'notify', "push activity_stream for user #{user.id}"
|
||||
|
||||
|
|
|
@ -39,17 +39,17 @@ module Sessions::Backend::Collections
|
|||
def self.push( user, client )
|
||||
|
||||
cache_key = 'user_' + user.id.to_s + '_push_collections'
|
||||
if !@@last_change[ user.id ]
|
||||
@@last_change[ user.id ] = {}
|
||||
if !client.last_change['push_collections']
|
||||
client.last_change['push_collections'] = {}
|
||||
end
|
||||
|
||||
collections = Sessions::CacheIn.get( cache_key ) || {}
|
||||
collections.each { | key, v |
|
||||
collection_cache_key = 'user_' + user.id.to_s + '_push_collections_' + key.to_s
|
||||
collection_time = Sessions::CacheIn.get_time( collection_cache_key, { :ignore_expire => true } )
|
||||
if collection_time && @@last_change[ user.id ][ key ] != collection_time
|
||||
if collection_time && client.last_change['push_collections'][ key ] != collection_time
|
||||
|
||||
@@last_change[ user.id ][ key ] = collection_time
|
||||
client.last_change['push_collections'][ key ] = collection_time
|
||||
push_collections = Sessions::CacheIn.get( collection_cache_key, { :ignore_expire => true } )
|
||||
|
||||
client.log 'notify', "push push_collections #{key} for user #{user.id}"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Sessions::Backend::RecentViewed
|
||||
@@last_change = {}
|
||||
|
||||
def self.worker( user, worker )
|
||||
cache_key = 'user_' + user.id.to_s + '_recent_viewed'
|
||||
|
@ -21,8 +20,8 @@ module Sessions::Backend::RecentViewed
|
|||
def self.push( user, client )
|
||||
cache_key = 'user_' + user.id.to_s + '_recent_viewed'
|
||||
recent_viewed_time = Sessions::CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if recent_viewed_time && @@last_change[ user.id ] != recent_viewed_time
|
||||
@@last_change[ user.id ] = recent_viewed_time
|
||||
if recent_viewed_time && client.last_change['recent_viewed'] != recent_viewed_time
|
||||
client.last_change['recent_viewed'] = recent_viewed_time
|
||||
recent_viewed = Sessions::CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
client.log 'notify', "push recent_viewed for user #{user.id}"
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Sessions::Backend::Rss
|
||||
@@last_change = {}
|
||||
|
||||
def self.worker( user, worker )
|
||||
cache_key = 'user_' + user.id.to_s + '_rss'
|
||||
|
@ -23,8 +22,8 @@ module Sessions::Backend::Rss
|
|||
cache_key = 'user_' + user.id.to_s + '_rss'
|
||||
|
||||
rss_items_time = Sessions::CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if rss_items_time && @@last_change[ user.id ] != rss_items_time
|
||||
@@last_change[ user.id ] = rss_items_time
|
||||
if rss_items_time && client.last_change['rss'] != rss_items_time
|
||||
client.last_change['rss'] = rss_items_time
|
||||
rss_items = Sessions::CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
client.log 'notify', "push rss for user #{user.id}"
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Sessions::Backend::TicketCreate
|
||||
@@last_change = {}
|
||||
|
||||
def self.worker( user, worker )
|
||||
cache_key = 'user_' + user.id.to_s + '_ticket_create_attributes'
|
||||
|
@ -22,8 +21,8 @@ module Sessions::Backend::TicketCreate
|
|||
cache_key = 'user_' + user.id.to_s + '_ticket_create_attributes'
|
||||
|
||||
ticket_create_attributes_time = Sessions::CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if ticket_create_attributes_time && @@last_change[ user.id ] != ticket_create_attributes_time
|
||||
@@last_change[ user.id ] = ticket_create_attributes_time
|
||||
if ticket_create_attributes_time && client.last_change['ticket_create_attributes'] != ticket_create_attributes_time
|
||||
client.last_change['ticket_create_attributes'] = ticket_create_attributes_time
|
||||
create_attributes = Sessions::CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
users = {}
|
||||
create_attributes[:owner_id].each {|user_id|
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Sessions::Backend::TicketOverviewIndex
|
||||
@@last_change = {}
|
||||
|
||||
def self.worker( user, worker )
|
||||
cache_key = 'user_' + user.id.to_s + '_overview'
|
||||
|
@ -22,8 +21,8 @@ module Sessions::Backend::TicketOverviewIndex
|
|||
def self.push( user, client )
|
||||
cache_key = 'user_' + user.id.to_s + '_overview'
|
||||
overview_time = Sessions::CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if overview_time && @@last_change[ user.id ] != overview_time
|
||||
@@last_change[ user.id ] = overview_time
|
||||
if overview_time && client.last_change['overview'] != overview_time
|
||||
client.last_change['overview'] = overview_time
|
||||
overview = Sessions::CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
|
||||
client.log 'notify', "push overview for user #{user.id}"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Sessions::Backend::TicketOverviewList
|
||||
@@last_change = {}
|
||||
|
||||
def self.worker( user, worker )
|
||||
overviews = Ticket::Overviews.all(
|
||||
|
@ -30,13 +29,13 @@ module Sessions::Backend::TicketOverviewList
|
|||
overviews.each { |overview|
|
||||
cache_key = 'user_' + user.id.to_s + '_overview_data_' + overview.link
|
||||
|
||||
if !@@last_change[ user.id ]
|
||||
@@last_change[ user.id ] = {}
|
||||
if !client.last_change['overview_list']
|
||||
client.last_change['overview_list'] = {}
|
||||
end
|
||||
|
||||
overview_data_time = Sessions::CacheIn.get_time( cache_key, { :ignore_expire => true } )
|
||||
if overview_data_time && @@last_change[ user.id ][overview.link] != overview_data_time
|
||||
@@last_change[ user.id ][overview.link] = overview_data_time
|
||||
if overview_data_time && client.last_change['overview_list'][overview.link] != overview_data_time
|
||||
client.last_change['overview_list'][overview.link] = overview_data_time
|
||||
overview_data = Sessions::CacheIn.get( cache_key, { :ignore_expire => true } )
|
||||
client.log 'notify', "push overview_data #{overview.link} for user #{user.id}"
|
||||
users = {}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
class Sessions::Client
|
||||
|
||||
attr_accessor :last_change
|
||||
|
||||
def initialize( client_id )
|
||||
@client_id = client_id
|
||||
@cache_key = ''
|
||||
@data = {}
|
||||
@pushed = {}
|
||||
@last_change = {}
|
||||
self.log 'notify', "---client start ws connection---"
|
||||
self.fetch
|
||||
self.log 'notify', "---client exiting ws connection---"
|
||||
|
|
Loading…
Reference in a new issue