Moved to Model.lookup() for asset generation to speed up.

This commit is contained in:
Martin Edenhofer 2014-08-13 13:32:43 +02:00
parent 47e89388bf
commit e51b376b43
7 changed files with 13 additions and 13 deletions

View file

@ -70,7 +70,7 @@ curl http://localhost/api/v1/users.json -v -u #{login}:#{password}
end
users_all = []
users.each {|user|
users_all.push User.find( user.id ).attributes_with_associations
users_all.push User.lookup( :id => user.id ).attributes_with_associations
}
render :json => users_all, :status => :ok
end

View file

@ -33,7 +33,7 @@ returns
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.find( self[ item ] )
user = User.lookup( :id => self[ item ] )
data = user.assets( data )
end
end

View file

@ -23,7 +23,7 @@ returns
def assets (data)
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self['created_by_id'] ]
user = User.find( self['created_by_id'] )
user = User.lookup( :id => self['created_by_id'] )
data = user.assets( data )
end

View file

@ -33,7 +33,7 @@ returns
if data[ Organization.to_app_model ][ self.id ]['member_ids']
data[ Organization.to_app_model ][ self.id ]['member_ids'].each {|user_id|
if !data[ User.to_app_model ][ user_id ]
user = User.find( user_id )
user = User.lookup( :id => user_id )
data = user.assets( data )
end
}
@ -42,7 +42,7 @@ returns
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ][ self[ item ] ]
user = User.find( self[ item ] )
user = User.lookup( :id => self[ item ] )
data = user.assets( data )
end
end

View file

@ -44,7 +44,7 @@ returns
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.find( self[ item ] )
user = User.lookup( :id => self[ item ] )
data = user.assets( data )
end
end

View file

@ -27,12 +27,12 @@ returns
data[ Ticket.to_app_model ] = {}
end
if !data[ Ticket.to_app_model ][ self.id ]
data[ Ticket.to_app_model ][ self.id ] = self.attributes
data[ Ticket.to_app_model ][ self.id ] = self.attributes_with_associations
end
['created_by_id', 'updated_by_id', 'owner_id', 'customer_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.find( self[ item ] )
user = User.lookup( :id => self[ item ] )
data = user.assets( data )
end
end

View file

@ -46,7 +46,7 @@ returns
# get roles
if attributes['role_ids']
attributes['role_ids'].each {|role_id|
role = Role.find(role_id)
role = Role.lookup( :id => role_id )
data = role.assets( data )
}
end
@ -54,7 +54,7 @@ returns
# get groups
if attributes['group_ids']
attributes['group_ids'].each {|group_id|
group = Group.find(group_id)
group = Group.lookup( :id => group_id )
data = group.assets( data )
}
end
@ -62,21 +62,21 @@ returns
# get groups
if attributes['organization_ids']
attributes['organization_ids'].each {|organization_id|
organization = Organization.find(organization_id)
organization = Organization.lookup( :id => organization_id )
data = organization.assets( data )
}
end
end
if self.organization_id
if !data[ Organization.to_app_model ] || !data[ Organization.to_app_model ][ self.organization_id ]
organization = Organization.find( self.organization_id )
organization = Organization.lookup( :id => self.organization_id )
data = organization.assets( data )
end
end
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ][ self[ item ] ]
user = User.find( self[ item ] )
user = User.lookup( :id => self[ item ] )
data = user.assets( data )
end
end