fix transfer
This commit is contained in:
parent
05f5261668
commit
f87d891daa
|
|
@ -254,15 +254,17 @@ def transfer_guide_elements_bulk():
|
|||
|
||||
for guide in tqdm(Guide.objects.all(),
|
||||
desc='update count_of_initial_objects field values'):
|
||||
descendants = GuideElement.objects.get_root_node(guide).get_descendants()
|
||||
if descendants:
|
||||
count_of_initial_objects = descendants.filter(
|
||||
guide_element_type__name__in=['EstablishmentNode', 'WineNode']).count()
|
||||
guide.count_related_objects = count_of_initial_objects
|
||||
objects_to_update.append(guide)
|
||||
root_node = GuideElement.objects.get_root_node(guide)
|
||||
if root_node:
|
||||
descendants = root_node.get_descendants()
|
||||
if descendants:
|
||||
count_related_objects = descendants.filter(
|
||||
guide_element_type__name__in=['EstablishmentNode', 'WineNode']).count()
|
||||
guide.count_related_objects = count_related_objects
|
||||
objects_to_update.append(guide)
|
||||
|
||||
# update count_of_initial_objects field values
|
||||
Guide.objects.bulk_update(objects_to_update, ['count_objects_during_init', ])
|
||||
Guide.objects.bulk_update(objects_to_update, ['count_related_objects', ])
|
||||
print(f'COUNT OF UPDATED OBJECTS: {len(objects_to_update)}')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user