mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Specify batch size for bulk_update()
This commit is contained in:
parent
d34b9ee00e
commit
88aa3a4e19
@ -13,7 +13,7 @@ def update_parents_children(prefix):
|
|||||||
parents = prefix.get_parents(include_self=True).annotate_hierarchy()
|
parents = prefix.get_parents(include_self=True).annotate_hierarchy()
|
||||||
for parent in parents:
|
for parent in parents:
|
||||||
parent._children = parent.hierarchy_children
|
parent._children = parent.hierarchy_children
|
||||||
Prefix.objects.bulk_update(parents, ['_children'])
|
Prefix.objects.bulk_update(parents, ['_children'], batch_size=100)
|
||||||
|
|
||||||
|
|
||||||
def update_children_depth(prefix):
|
def update_children_depth(prefix):
|
||||||
@ -23,7 +23,7 @@ def update_children_depth(prefix):
|
|||||||
children = prefix.get_children(include_self=True).annotate_hierarchy()
|
children = prefix.get_children(include_self=True).annotate_hierarchy()
|
||||||
for child in children:
|
for child in children:
|
||||||
child._depth = child.hierarchy_depth
|
child._depth = child.hierarchy_depth
|
||||||
Prefix.objects.bulk_update(children, ['_depth'])
|
Prefix.objects.bulk_update(children, ['_depth'], batch_size=100)
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Prefix)
|
@receiver(post_save, sender=Prefix)
|
||||||
|
Loading…
Reference in New Issue
Block a user