diff --git a/parsers/survex.py b/parsers/survex.py index 796161b..b5817d3 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -1837,9 +1837,7 @@ class LoadingSurvex: nlegstotal = 0 self.relativefilename = path - # Cache for survex blocks to save at the end - self._pending_parent_saves = set() - self._pending_block_saves = set() + self._pending_block_saves = set() # Cache for survex blocks to save at the end #self.IdentifyCave(path, svxid, depth) # this will produce null for survex files which are geographic collections self.currentsurvexfile = survexblock.survexfile @@ -2002,12 +2000,12 @@ class LoadingSurvex: self.fix_undated(survexblock) self.fix_anonymous(survexblock) - # This is the most time-consuming step within *end processing: 47% + # This is the most time-consuming step within *end processing: was 47% # Instead of saving parent here, cache for later if hasattr(survexblock, 'parent') and survexblock.parent: self._pending_block_saves.add(survexblock) try: - # This is the second most time-consuming step within *end processing: 35% + # This is the second most time-consuming step within *end processing: was 35% self._pending_block_saves.add(survexblock) # update_fields=["legsall", "legslength"] except Exception: @@ -2136,8 +2134,8 @@ class LoadingSurvex: # print(f" ! Block {block} is invalid: {e}") try: BATCH_SIZE = 900 - for i in range(0, len(valid_blocks), BATCH_SIZE): - SurvexBlock.objects.bulk_update(valid_blocks[i:i+BATCH_SIZE], ["legsall", "legslength", "parent"]) + for i in range(0, len(blocks), BATCH_SIZE): + SurvexBlock.objects.bulk_update(blocks[i:i+BATCH_SIZE], ["legsall", "legslength", "parent"]) except Exception as e: print(f"\n !! Error in bulk_update for survexblocks: {e}", file=sys.stderr)