From 558306a629a924e4de53dd61974e1bd61d182017 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 10 Mar 2012 02:33:03 +0100 Subject: [PATCH] dont look over places/events if empty annotation --- pandora/annotation/tasks.py | 54 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index 4dc6ad19..c33e77f1 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -23,20 +23,21 @@ def update_matching_events(id): for e in a.events.all(): e.update_matches() - names = {} - 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'])] + if a.findvalue: + names = {} + 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() - update = [] - for i in names: - for name in names[i]: - if name.lower() in value: - update.append(i) - break - if update: - for e in Event.objects.filter(id__in=update): - e.update_matches() + value = a.findvalue.lower() + update = [] + for i in names: + for name in names[i]: + if name.lower() in value: + update.append(i) + break + if update: + for e in Event.objects.filter(id__in=update): + e.update_matches() @task(ignore_resulsts=True, queue='default') def update_matching_places(id): @@ -52,19 +53,20 @@ def update_matching_places(id): for p in a.places.all(): p.update_matches() - names = {} - for n in Place.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() - update = [] - for i in names: - for name in names[i]: - if name.lower() in value: - update.append(i) - break - if update: - for e in Place.objects.filter(id__in=update): - e.update_matches() + if a.findvalue: + names = {} + for n in Place.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() + update = [] + for i in names: + for name in names[i]: + if name.lower() in value: + update.append(i) + break + if update: + for e in Place.objects.filter(id__in=update): + e.update_matches() @task(ignore_resulsts=True, queue='default') def update_item(id):