mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 12:17:52 +00:00
dammit, SB creation now failing, and that was OK before
This commit is contained in:
@@ -589,14 +589,37 @@ class LoadingSurvex:
|
||||
try:
|
||||
for i, chunk in enumerate(safe_chunks):
|
||||
print(f" - Saving chunk {i+1} ({len(chunk)} blocks)...", file=sys.stderr)
|
||||
SurvexBlock.objects.bulk_create(
|
||||
chunk,
|
||||
update_conflicts=True, # root item probably exists already
|
||||
# update_fields needed if we allow conflict update
|
||||
update_fields=['name', 'title', 'parent', 'date',
|
||||
'expedition', 'survexfile', 'scanswallet', 'legsall', 'legslength', 'foreigners',],
|
||||
unique_fields=['_blockid']
|
||||
)
|
||||
try:
|
||||
SurvexBlock.objects.bulk_create(
|
||||
chunk,
|
||||
update_conflicts=True, # root item probably exists already
|
||||
# update_fields needed if we allow conflict update
|
||||
update_fields=['name', 'title', 'parent', 'date',
|
||||
'expedition', 'survexfile', 'scanswallet', 'legsall', 'legslength', 'foreigners',],
|
||||
unique_fields=['_blockid']
|
||||
)
|
||||
except Exception as e:
|
||||
|
||||
message = f"\n ! - EXCEPTION '{e}' - in SB bulk update. Falling back onto sequential updates for this chunk"
|
||||
print(message)
|
||||
print(message, file=sys.stderr)
|
||||
stash_data_issue(parser="survex", message=message)
|
||||
|
||||
for sb in chunk:
|
||||
got_obj, created = SurvexBlock.objects.get_or_create(
|
||||
survexblock=sb.survexblock,
|
||||
defaults={'survexblockblock': sb.survexblock} # Fields to set only if creating
|
||||
)
|
||||
if created:
|
||||
print(f" - {sb} Created", file=sys.stderr)
|
||||
else:
|
||||
# update the block if it changed
|
||||
got_obj.block = sb.block
|
||||
got_obj.save()
|
||||
# print(f" - {sb} SAVED", file=sys.stderr)
|
||||
print(f" - {len(chunk)} SBs saved to db", file=sys.stderr)
|
||||
|
||||
|
||||
print(" - Success: Entire tree of survexblocks saved to db.", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Failed at chunk {i+1}: {e}", file=sys.stderr)
|
||||
@@ -723,10 +746,10 @@ class LoadingSurvex:
|
||||
defaults={'survexblockblock': pr.survexblock} # Fields to set only if creating
|
||||
)
|
||||
if created:
|
||||
print(f" - {qm} Created", file=sys.stderr)
|
||||
print(f" - {pr} Created", file=sys.stderr)
|
||||
else:
|
||||
# update the block if it changed
|
||||
got_obj.block = qm.block
|
||||
got_obj.survexblock = pr.survexblock
|
||||
got_obj.save()
|
||||
# print(f" - {qm} SAVED", file=sys.stderr)
|
||||
print(f" - PRs saved to db", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user