2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-02-08 04:27:45 +00:00

update only changed fields optimisation now done

This commit is contained in:
2026-01-28 16:10:30 +00:00
parent 95352a0d18
commit 7b6a066b91
2 changed files with 8 additions and 7 deletions

View File

@@ -329,7 +329,7 @@ class Wallet(models.Model):
return None
else:
self.walletyear = datetime.date(year, 1, 1)
self.save()
self.save(update_fields=["walletdate"])
return str(year)
# Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it

View File

@@ -106,7 +106,7 @@ def set_walletdate(w):
if not w.date(): # sets .walletdate as a side-effect if it gets it from JSON
d = datewallet(w, earliest) # Not in JSON, so checks all the survex blocks
w.walletdate = d
w.save()
w.save(update_fields=["walletdate"])
def stash_data_issue(parser=None, message=None, url=None, sb=None):
"""Avoid hitting the database for error messages until the end of the import
@@ -1212,7 +1212,7 @@ class LoadingSurvex:
Currently this just sets a flag that the survex block is not CUCC
"""
survexblock.foreigners = True
survexblock.save()
survexblock.save(update_fields=["foreigners"])
def LoadSurvexRef(self, survexblock, args):
"""Interpret the *ref record, and all the many variants
@@ -1303,8 +1303,9 @@ class LoadingSurvex:
else:
survexblock.scanswallet = manywallets[0] # this is a ForeignKey field
survexblock.save()
# This is where we chould check that the wallet JSON contains a link to the survexfile
# Only save if changed
survexblock.save(update_fields=["scanswallet"])
# This is where we should check that the wallet JSON contains a link to the survexfile
# and that the JSON date and walletdate are set correctly to the survexblock date.
set_walletdate(survexblock.scanswallet)
else:
@@ -1555,7 +1556,7 @@ class LoadingSurvex:
# print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr)
if not cave.survex_file:
cave.survex_file = svxid + ".svx"
cave.save()
cave.save(update_fields=["survex_file"])
# message = f" - '{cave}' had no survex_file set - setting '{svxid}.svx' writing to {cave.filename})"
message = f" - '{cave}' has no survex_file set - need to set to '{svxid}.svx' in {cave.filename})"
print("\n",message,file=sys.stderr)
@@ -2739,7 +2740,7 @@ def parse_one_file(fpath): # --------------------------------------in progress--
cave_svxpath = cave.survex_file[:-4] # remove .svx
else:
cave.survex_file = svxpath + ".svx"
cave.save()
cave.save(update_fields=["survex_file"])
cave_svxpath = svxpath
try:
fileroot = SurvexFile.objects.get(path=cave_svxpath)