Performance: Don't check record associations if record is already present in assets structure.
This commit is contained in:
parent
cccec58c2e
commit
20c7cf9502
14 changed files with 204 additions and 191 deletions
|
@ -29,7 +29,8 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model ][ id ]
|
return data if data[ app_model ][ id ]
|
||||||
|
|
||||||
local_attributes = attributes_with_association_ids
|
local_attributes = attributes_with_association_ids
|
||||||
|
|
||||||
local_attributes['object'] = ObjectLookup.by_id(local_attributes['activity_stream_object_id'])
|
local_attributes['object'] = ObjectLookup.by_id(local_attributes['activity_stream_object_id'])
|
||||||
|
@ -40,7 +41,6 @@ returns
|
||||||
data[ app_model ][ id ] = local_attributes
|
data[ app_model ][ id ] = local_attributes
|
||||||
|
|
||||||
ApplicationModel.assets_of_object_list([local_attributes], data)
|
ApplicationModel.assets_of_object_list([local_attributes], data)
|
||||||
end
|
|
||||||
|
|
||||||
return data if !self['created_by_id']
|
return data if !self['created_by_id']
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model ][ id ]
|
return data if data[ app_model ][ id ]
|
||||||
|
|
||||||
attributes = attributes_with_association_ids
|
attributes = attributes_with_association_ids
|
||||||
|
|
||||||
# remove passwords if use is no admin
|
# remove passwords if use is no admin
|
||||||
|
@ -49,7 +50,6 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
data[ self.class.to_app_model ][ id ] = attributes
|
data[ self.class.to_app_model ][ id ] = attributes
|
||||||
end
|
|
||||||
|
|
||||||
return data if !self['created_by_id'] && !self['updated_by_id']
|
return data if !self['created_by_id'] && !self['updated_by_id']
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,20 @@ returns
|
||||||
def assets(data)
|
def assets(data)
|
||||||
|
|
||||||
app_model_chat_session = Chat::Session.to_app_model
|
app_model_chat_session = Chat::Session.to_app_model
|
||||||
app_model_chat = Chat.to_app_model
|
|
||||||
app_model_user = User.to_app_model
|
|
||||||
|
|
||||||
data[ app_model_chat_session ] ||= {}
|
if !data[ app_model_chat_session ]
|
||||||
|
data[ app_model_chat_session ] = {}
|
||||||
|
end
|
||||||
|
return data if data[ app_model_chat_session ][ id ]
|
||||||
|
|
||||||
if !data[ app_model_chat_session ][ id ]
|
|
||||||
data[ app_model_chat_session ][ id ] = attributes_with_association_ids
|
data[ app_model_chat_session ][ id ] = attributes_with_association_ids
|
||||||
data[ app_model_chat_session ][ id ]['messages'] = []
|
data[ app_model_chat_session ][ id ]['messages'] = []
|
||||||
messages.each do |message|
|
messages.each do |message|
|
||||||
data[ app_model_chat_session ][ id ]['messages'].push message.attributes
|
data[ app_model_chat_session ][ id ]['messages'].push message.attributes
|
||||||
end
|
end
|
||||||
data[ app_model_chat_session ][ id ]['tags'] = tag_list
|
data[ app_model_chat_session ][ id ]['tags'] = tag_list
|
||||||
end
|
|
||||||
|
|
||||||
|
app_model_chat = Chat.to_app_model
|
||||||
if !data[ app_model_chat ] || !data[ app_model_chat ][ chat_id ]
|
if !data[ app_model_chat ] || !data[ app_model_chat ][ chat_id ]
|
||||||
chat = Chat.lookup(id: chat_id)
|
chat = Chat.lookup(id: chat_id)
|
||||||
if chat
|
if chat
|
||||||
|
@ -45,6 +45,7 @@ returns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
app_model_user = User.to_app_model
|
||||||
%w[created_by_id updated_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
next if data[ app_model_user ] && data[ app_model_user ][ self[ local_user_id ] ]
|
next if data[ app_model_user ] && data[ app_model_user ][ self[ local_user_id ] ]
|
||||||
|
|
|
@ -29,13 +29,14 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ User.to_app_model ]
|
return data if data[ app_model ][ id ]
|
||||||
data[ User.to_app_model ] = {}
|
|
||||||
end
|
|
||||||
if !data[ app_model ][ id ]
|
|
||||||
data[ app_model ][ id ] = attributes_with_association_ids
|
data[ app_model ][ id ] = attributes_with_association_ids
|
||||||
data = assets_of_selector('condition', data)
|
data = assets_of_selector('condition', data)
|
||||||
data = assets_of_selector('perform', data)
|
data = assets_of_selector('perform', data)
|
||||||
|
|
||||||
|
if !data[ User.to_app_model ]
|
||||||
|
data[ User.to_app_model ] = {}
|
||||||
end
|
end
|
||||||
%w[created_by_id updated_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
|
|
|
@ -29,7 +29,8 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model ][ id ]
|
return data if data[ app_model ][ id ]
|
||||||
|
|
||||||
local_attributes = attributes_with_association_ids
|
local_attributes = attributes_with_association_ids
|
||||||
|
|
||||||
local_attributes['object'] = ObjectLookup.by_id(local_attributes['object_lookup_id'])
|
local_attributes['object'] = ObjectLookup.by_id(local_attributes['object_lookup_id'])
|
||||||
|
@ -40,7 +41,6 @@ returns
|
||||||
data[ app_model ][ id ] = local_attributes
|
data[ app_model ][ id ] = local_attributes
|
||||||
|
|
||||||
ApplicationModel.assets_of_object_list([local_attributes], data)
|
ApplicationModel.assets_of_object_list([local_attributes], data)
|
||||||
end
|
|
||||||
|
|
||||||
return data if !self['created_by_id'] && !self['updated_by_id']
|
return data if !self['created_by_id'] && !self['updated_by_id']
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,19 @@ returns
|
||||||
def assets(data)
|
def assets(data)
|
||||||
|
|
||||||
app_model_organization = Organization.to_app_model
|
app_model_organization = Organization.to_app_model
|
||||||
app_model_user = User.to_app_model
|
|
||||||
|
|
||||||
if !data[ app_model_organization ]
|
if !data[ app_model_organization ]
|
||||||
data[ app_model_organization ] = {}
|
data[ app_model_organization ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model_user ]
|
return data if data[ app_model_organization ][ id ]
|
||||||
data[ app_model_user ] = {}
|
|
||||||
end
|
|
||||||
if !data[ app_model_organization ][ id ]
|
|
||||||
local_attributes = attributes_with_association_ids
|
local_attributes = attributes_with_association_ids
|
||||||
|
|
||||||
# set temp. current attributes to assets pool to prevent
|
# set temp. current attributes to assets pool to prevent
|
||||||
# loops, will be updated with lookup attributes later
|
# loops, will be updated with lookup attributes later
|
||||||
data[ app_model_organization ][ id ] = local_attributes
|
data[ app_model_organization ][ id ] = local_attributes
|
||||||
|
|
||||||
|
app_model_user = User.to_app_model
|
||||||
if local_attributes['member_ids'].present?
|
if local_attributes['member_ids'].present?
|
||||||
|
|
||||||
# feature used for different purpose; do limit references
|
# feature used for different purpose; do limit references
|
||||||
|
@ -57,7 +55,11 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
data[ app_model_organization ][ id ] = local_attributes
|
data[ app_model_organization ][ id ] = local_attributes
|
||||||
|
|
||||||
|
if !data[ app_model_user ]
|
||||||
|
data[ app_model_user ] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
%w[created_by_id updated_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
next if data[ app_model_user ][ self[ local_user_id ] ]
|
next if data[ app_model_user ][ self[ local_user_id ] ]
|
||||||
|
|
|
@ -25,15 +25,17 @@ returns
|
||||||
def assets(data)
|
def assets(data)
|
||||||
|
|
||||||
app_model_overview = Overview.to_app_model
|
app_model_overview = Overview.to_app_model
|
||||||
app_model_user = User.to_app_model
|
|
||||||
|
|
||||||
if !data[ app_model_overview ]
|
if !data[ app_model_overview ]
|
||||||
data[ app_model_overview ] = {}
|
data[ app_model_overview ] = {}
|
||||||
end
|
end
|
||||||
|
return data if data[ app_model_overview ][ id ]
|
||||||
|
|
||||||
|
app_model_user = User.to_app_model
|
||||||
if !data[ app_model_user ]
|
if !data[ app_model_user ]
|
||||||
data[ app_model_user ] = {}
|
data[ app_model_user ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model_overview ][ id ]
|
|
||||||
data[ app_model_overview ][ id ] = attributes_with_association_ids
|
data[ app_model_overview ][ id ] = attributes_with_association_ids
|
||||||
user_ids&.each do |local_user_id|
|
user_ids&.each do |local_user_id|
|
||||||
next if data[ app_model_user ][ local_user_id ]
|
next if data[ app_model_user ][ local_user_id ]
|
||||||
|
@ -44,7 +46,7 @@ returns
|
||||||
data = user.assets(data)
|
data = user.assets(data)
|
||||||
end
|
end
|
||||||
data = assets_of_selector('condition', data)
|
data = assets_of_selector('condition', data)
|
||||||
end
|
|
||||||
%w[created_by_id updated_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
next if data[ app_model_user ][ self[ local_user_id ] ]
|
next if data[ app_model_user ][ self[ local_user_id ] ]
|
||||||
|
|
|
@ -29,7 +29,8 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model ][ id ]
|
return data if data[ app_model ][ id ]
|
||||||
|
|
||||||
local_attributes = attributes_with_association_ids
|
local_attributes = attributes_with_association_ids
|
||||||
|
|
||||||
local_attributes['object'] = ObjectLookup.by_id(local_attributes['recent_view_object_id'])
|
local_attributes['object'] = ObjectLookup.by_id(local_attributes['recent_view_object_id'])
|
||||||
|
@ -39,7 +40,6 @@ returns
|
||||||
data[ app_model ][ id ] = local_attributes
|
data[ app_model ][ id ] = local_attributes
|
||||||
|
|
||||||
ApplicationModel.assets_of_object_list([local_attributes], data)
|
ApplicationModel.assets_of_object_list([local_attributes], data)
|
||||||
end
|
|
||||||
|
|
||||||
return data if !self['created_by_id']
|
return data if !self['created_by_id']
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model ][ id ]
|
return data if data[ app_model ][ id ]
|
||||||
|
|
||||||
local_attributes = attributes_with_association_ids
|
local_attributes = attributes_with_association_ids
|
||||||
|
|
||||||
# set temp. current attributes to assets pool to prevent
|
# set temp. current attributes to assets pool to prevent
|
||||||
|
@ -44,7 +45,6 @@ returns
|
||||||
|
|
||||||
data = group.assets(data)
|
data = group.assets(data)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return data if !self['created_by_id'] && !self['updated_by_id']
|
return data if !self['created_by_id'] && !self['updated_by_id']
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,12 @@ returns
|
||||||
def assets (data)
|
def assets (data)
|
||||||
|
|
||||||
app_model_sla = Sla.to_app_model
|
app_model_sla = Sla.to_app_model
|
||||||
app_model_user = User.to_app_model
|
|
||||||
|
|
||||||
if !data[ app_model_sla ]
|
if !data[ app_model_sla ]
|
||||||
data[ app_model_sla ] = {}
|
data[ app_model_sla ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model_user ]
|
return data if data[ app_model_sla ][ id ]
|
||||||
data[ app_model_user ] = {}
|
|
||||||
end
|
|
||||||
if !data[ app_model_sla ][ id ]
|
|
||||||
data[ app_model_sla ][ id ] = attributes_with_association_ids
|
data[ app_model_sla ][ id ] = attributes_with_association_ids
|
||||||
data = assets_of_selector('condition', data)
|
data = assets_of_selector('condition', data)
|
||||||
if calendar_id
|
if calendar_id
|
||||||
|
@ -42,7 +39,12 @@ returns
|
||||||
data = calendar.assets(data)
|
data = calendar.assets(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
app_model_user = User.to_app_model
|
||||||
|
if !data[ app_model_user ]
|
||||||
|
data[ app_model_user ] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
%w[created_by_id updated_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
next if data[ app_model_user ][ self[ local_user_id ] ]
|
next if data[ app_model_user ][ self[ local_user_id ] ]
|
||||||
|
|
|
@ -24,8 +24,14 @@ returns
|
||||||
|
|
||||||
def assets(data)
|
def assets(data)
|
||||||
|
|
||||||
app_model_ticket = Ticket.to_app_model
|
|
||||||
app_model_article = Ticket::Article.to_app_model
|
app_model_article = Ticket::Article.to_app_model
|
||||||
|
|
||||||
|
if !data[ app_model_article ]
|
||||||
|
data[ app_model_article ] = {}
|
||||||
|
end
|
||||||
|
return data if data[ app_model_article ][ id ]
|
||||||
|
|
||||||
|
app_model_ticket = Ticket.to_app_model
|
||||||
app_model_user = User.to_app_model
|
app_model_user = User.to_app_model
|
||||||
|
|
||||||
if !data[ app_model_ticket ]
|
if !data[ app_model_ticket ]
|
||||||
|
@ -38,12 +44,7 @@ returns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !data[ app_model_article ]
|
|
||||||
data[ app_model_article ] = {}
|
|
||||||
end
|
|
||||||
if !data[ app_model_article ][ id ]
|
|
||||||
data[ app_model_article ][ id ] = attributes_with_association_ids
|
data[ app_model_article ][ id ] = attributes_with_association_ids
|
||||||
end
|
|
||||||
|
|
||||||
%w[created_by_id updated_by_id origin_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id origin_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
|
|
|
@ -24,14 +24,16 @@ returns
|
||||||
def assets(data)
|
def assets(data)
|
||||||
|
|
||||||
app_model_ticket = Ticket.to_app_model
|
app_model_ticket = Ticket.to_app_model
|
||||||
app_model_user = User.to_app_model
|
|
||||||
|
|
||||||
if !data[ app_model_ticket ]
|
if !data[ app_model_ticket ]
|
||||||
data[ app_model_ticket ] = {}
|
data[ app_model_ticket ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model_ticket ][ id ]
|
return data if data[ app_model_ticket ][ id ]
|
||||||
|
|
||||||
data[ app_model_ticket ][ id ] = attributes_with_association_ids
|
data[ app_model_ticket ][ id ] = attributes_with_association_ids
|
||||||
end
|
|
||||||
|
app_model_user = User.to_app_model
|
||||||
|
|
||||||
%w[created_by_id updated_by_id owner_id customer_id].each do |local_user_id|
|
%w[created_by_id updated_by_id owner_id customer_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
next if data[ app_model_user ] && data[ app_model_user ][ self[ local_user_id ] ]
|
next if data[ app_model_user ] && data[ app_model_user ][ self[ local_user_id ] ]
|
||||||
|
|
|
@ -24,20 +24,22 @@ returns
|
||||||
|
|
||||||
def assets(data)
|
def assets(data)
|
||||||
|
|
||||||
app_model_overview = Trigger.to_app_model
|
app_model_trigger = Trigger.to_app_model
|
||||||
app_model_user = User.to_app_model
|
|
||||||
|
|
||||||
if !data[ app_model_overview ]
|
if !data[ app_model_trigger ]
|
||||||
data[ app_model_overview ] = {}
|
data[ app_model_trigger ] = {}
|
||||||
end
|
end
|
||||||
|
return data if data[ app_model_trigger ][ id ]
|
||||||
|
|
||||||
|
data[ app_model_trigger ][ id ] = attributes_with_association_ids
|
||||||
|
data = assets_of_selector('condition', data)
|
||||||
|
data = assets_of_selector('perform', data)
|
||||||
|
|
||||||
|
app_model_user = User.to_app_model
|
||||||
if !data[ app_model_user ]
|
if !data[ app_model_user ]
|
||||||
data[ app_model_user ] = {}
|
data[ app_model_user ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model_overview ][ id ]
|
|
||||||
data[ app_model_overview ][ id ] = attributes_with_association_ids
|
|
||||||
data = assets_of_selector('condition', data)
|
|
||||||
data = assets_of_selector('perform', data)
|
|
||||||
end
|
|
||||||
%w[created_by_id updated_by_id].each do |local_user_id|
|
%w[created_by_id updated_by_id].each do |local_user_id|
|
||||||
next if !self[ local_user_id ]
|
next if !self[ local_user_id ]
|
||||||
next if data[ app_model_user ][ self[ local_user_id ] ]
|
next if data[ app_model_user ][ self[ local_user_id ] ]
|
||||||
|
|
|
@ -30,7 +30,8 @@ returns
|
||||||
if !data[ app_model ]
|
if !data[ app_model ]
|
||||||
data[ app_model ] = {}
|
data[ app_model ] = {}
|
||||||
end
|
end
|
||||||
if !data[ app_model ][ id ]
|
return data if data[ app_model ][ id ]
|
||||||
|
|
||||||
local_attributes = attributes_with_association_ids
|
local_attributes = attributes_with_association_ids
|
||||||
|
|
||||||
# do not transfer crypted pw
|
# do not transfer crypted pw
|
||||||
|
@ -88,7 +89,6 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
data[ app_model ][ id ] = local_attributes
|
data[ app_model ][ id ] = local_attributes
|
||||||
end
|
|
||||||
|
|
||||||
# add organization
|
# add organization
|
||||||
if self.organization_id
|
if self.organization_id
|
||||||
|
|
Loading…
Reference in a new issue