diff options
Diffstat (limited to 'parsers/caves.py')
-rw-r--r-- | parsers/caves.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/parsers/caves.py b/parsers/caves.py index d1e7406..2bb2ccc 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -192,6 +192,8 @@ def readcave(filename): url = url[0], filename = filename) except: + # this slow db query happens on every cave, but on import we have all this in memory + # and don't need to do a db query. Fix this to speed it up! # need to cope with duplicates print(" ! FAILED to get only one CAVE when updating using: "+filename) kaves = models_caves.Cave.objects.all().filter(kataster_number=kataster_number[0]) @@ -206,6 +208,8 @@ def readcave(filename): c = k for area_slug in areas: + # this slow db query happens on every cave, but on import we have all this in memory + # and don't need to do a db query. Fix this to speed it up! area = models_caves.Area.objects.filter(short_name = area_slug) if area: newArea = area[0] @@ -216,6 +220,8 @@ def readcave(filename): primary = True for slug in slugs: try: + # this slow db query happens on every cave, but on import we have all this in memory + # and don't need to do a db query. Fix this to speed it up! cs = models_caves.CaveSlug.objects.update_or_create(cave = c, slug = slug, primary = primary) @@ -225,10 +231,13 @@ def readcave(filename): print(message) primary = False + for entrance in entrances: slug = getXML(entrance, "entranceslug", maxItems = 1, context = context)[0] letter = getXML(entrance, "letter", maxItems = 1, context = context)[0] try: + # this slow db query happens on every entrance, but on import we have all this in memory + # and don't need to do a db query. Fix this to speed it up! entrance = models_caves.Entrance.objects.get(entranceslug__slug = slug) ce = models_caves.CaveAndEntrance.objects.update_or_create(cave = c, entrance_letter = letter, entrance = entrance) except: |