It looks like this could be reasonably well optimised by changing root_stack and total_resources to use db queries instead of stack/resource navigation.
In engine.Stack, implement root_stack_id which queries for models.Stack.owner_id until the root is reached (bonus points for doing it in a single query)
change engine.Stack.root_stack to use root_stack_id, and deprecate it
change total_resources to do queries which build a list of stack IDs by recursively searching for owner_id. total resources is the count of models.Resource where stack_id in all stack IDs
I *might* have a crack at this on the plane. If I do I'll assign it to me
It looks like this could be reasonably well optimised by changing root_stack and total_resources to use db queries instead of stack/resource navigation.
In engine.Stack, implement root_stack_id which queries for models. Stack.owner_ id until the root is reached (bonus points for doing it in a single query)
change engine. Stack.root_ stack to use root_stack_id, and deprecate it
change total_resources to do queries which build a list of stack IDs by recursively searching for owner_id. total resources is the count of models.Resource where stack_id in all stack IDs
I *might* have a crack at this on the plane. If I do I'll assign it to me