avoid looking up item twice
This commit is contained in:
parent
7c53dca65b
commit
22f83288c5
3 changed files with 11 additions and 8 deletions
|
|
@ -15,8 +15,8 @@ def update_itemsort(id):
|
|||
|
||||
@task(ignore_results=True, queue='default')
|
||||
def update_file_paths(id):
|
||||
from item.models import Item
|
||||
from item.tasks import update_file_paths
|
||||
from item.models import Item, ItemFind
|
||||
p = models.Person.objects.get(pk=id)
|
||||
for i in Item.objects.filter(find__value__icontains=p.name).distinct():
|
||||
update_file_paths(i.public_id)
|
||||
items = ItemFind.objects.filter(key='name', value__icontains=p.name).values('item_id')
|
||||
for i in Item.objects.filter(id__in=items):
|
||||
i.update_file_paths()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue