dont look over places/events if empty annotation

This commit is contained in:
j 2012-03-10 02:33:03 +01:00
parent 80cb9c8faf
commit 558306a629

View file

@ -23,20 +23,21 @@ def update_matching_events(id):
for e in a.events.all(): for e in a.events.all():
e.update_matches() e.update_matches()
names = {} if a.findvalue:
for n in Event.objects.all().values('id', 'name', 'alternativeNames'): names = {}
names[n['id']] = [ox.decodeHtml(x) for x in [n['name']] + json.loads(n['alternativeNames'])] for n in Event.objects.all().values('id', 'name', 'alternativeNames'):
names[n['id']] = [ox.decodeHtml(x) for x in [n['name']] + json.loads(n['alternativeNames'])]
value = a.findvalue.lower() value = a.findvalue.lower()
update = [] update = []
for i in names: for i in names:
for name in names[i]: for name in names[i]:
if name.lower() in value: if name.lower() in value:
update.append(i) update.append(i)
break break
if update: if update:
for e in Event.objects.filter(id__in=update): for e in Event.objects.filter(id__in=update):
e.update_matches() e.update_matches()
@task(ignore_resulsts=True, queue='default') @task(ignore_resulsts=True, queue='default')
def update_matching_places(id): def update_matching_places(id):
@ -52,19 +53,20 @@ def update_matching_places(id):
for p in a.places.all(): for p in a.places.all():
p.update_matches() p.update_matches()
names = {} if a.findvalue:
for n in Place.objects.all().values('id', 'name', 'alternativeNames'): names = {}
names[n['id']] = [ox.decodeHtml(x) for x in [n['name']] + json.loads(n['alternativeNames'])] for n in Place.objects.all().values('id', 'name', 'alternativeNames'):
value = a.findvalue.lower() names[n['id']] = [ox.decodeHtml(x) for x in [n['name']] + json.loads(n['alternativeNames'])]
update = [] value = a.findvalue.lower()
for i in names: update = []
for name in names[i]: for i in names:
if name.lower() in value: for name in names[i]:
update.append(i) if name.lower() in value:
break update.append(i)
if update: break
for e in Place.objects.filter(id__in=update): if update:
e.update_matches() for e in Place.objects.filter(id__in=update):
e.update_matches()
@task(ignore_resulsts=True, queue='default') @task(ignore_resulsts=True, queue='default')
def update_item(id): def update_item(id):