Don't query stack tags twice
Retrieving the field from the db object triggers the query to stack_tags, so we don't need to do it a second time to retrieve the list of tags. Instead, use the data directly. Change-Id: Ibe6ac45d54afca6588b1b71ffa7278977d2f4d8a
This commit is contained in:
parent
681df8eb00
commit
39b772844d
@ -71,11 +71,8 @@ class Stack(
|
||||
raw_template.RawTemplate.get_by_id(
|
||||
context, db_stack['raw_template_id']))
|
||||
elif field == 'tags':
|
||||
if db_stack.get(field) is not None:
|
||||
stack['tags'] = stack_tag.StackTagList.get(
|
||||
context, db_stack['id'])
|
||||
else:
|
||||
stack['tags'] = None
|
||||
stack['tags'] = stack_tag.StackTagList.from_db_object(
|
||||
context, db_stack.get(field))
|
||||
else:
|
||||
stack[field] = db_stack.__dict__.get(field)
|
||||
stack._context = context
|
||||
|
@ -80,3 +80,8 @@ class StackTagList(
|
||||
@classmethod
|
||||
def delete(cls, context, stack_id):
|
||||
db_api.stack_tags_delete(context, stack_id)
|
||||
|
||||
@classmethod
|
||||
def from_db_object(cls, context, db_tags):
|
||||
if db_tags is not None:
|
||||
return base.obj_make_list(context, cls(), StackTag, db_tags)
|
||||
|
Loading…
x
Reference in New Issue
Block a user