mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 05:58:45 +00:00
update only changed fields optimisation now done
This commit is contained in:
@@ -329,7 +329,7 @@ class Wallet(models.Model):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
self.walletyear = datetime.date(year, 1, 1)
|
self.walletyear = datetime.date(year, 1, 1)
|
||||||
self.save()
|
self.save(update_fields=["walletdate"])
|
||||||
return str(year)
|
return str(year)
|
||||||
|
|
||||||
# Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it
|
# Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ def set_walletdate(w):
|
|||||||
if not w.date(): # sets .walletdate as a side-effect if it gets it from JSON
|
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
|
d = datewallet(w, earliest) # Not in JSON, so checks all the survex blocks
|
||||||
w.walletdate = d
|
w.walletdate = d
|
||||||
w.save()
|
w.save(update_fields=["walletdate"])
|
||||||
|
|
||||||
def stash_data_issue(parser=None, message=None, url=None, sb=None):
|
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
|
"""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
|
Currently this just sets a flag that the survex block is not CUCC
|
||||||
"""
|
"""
|
||||||
survexblock.foreigners = True
|
survexblock.foreigners = True
|
||||||
survexblock.save()
|
survexblock.save(update_fields=["foreigners"])
|
||||||
|
|
||||||
def LoadSurvexRef(self, survexblock, args):
|
def LoadSurvexRef(self, survexblock, args):
|
||||||
"""Interpret the *ref record, and all the many variants
|
"""Interpret the *ref record, and all the many variants
|
||||||
@@ -1303,8 +1303,9 @@ class LoadingSurvex:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
survexblock.scanswallet = manywallets[0] # this is a ForeignKey field
|
survexblock.scanswallet = manywallets[0] # this is a ForeignKey field
|
||||||
survexblock.save()
|
# Only save if changed
|
||||||
# This is where we chould check that the wallet JSON contains a link to the survexfile
|
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.
|
# and that the JSON date and walletdate are set correctly to the survexblock date.
|
||||||
set_walletdate(survexblock.scanswallet)
|
set_walletdate(survexblock.scanswallet)
|
||||||
else:
|
else:
|
||||||
@@ -1555,7 +1556,7 @@ class LoadingSurvex:
|
|||||||
# print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr)
|
# print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr)
|
||||||
if not cave.survex_file:
|
if not cave.survex_file:
|
||||||
cave.survex_file = svxid + ".svx"
|
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}' 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})"
|
message = f" - '{cave}' has no survex_file set - need to set to '{svxid}.svx' in {cave.filename})"
|
||||||
print("\n",message,file=sys.stderr)
|
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
|
cave_svxpath = cave.survex_file[:-4] # remove .svx
|
||||||
else:
|
else:
|
||||||
cave.survex_file = svxpath + ".svx"
|
cave.survex_file = svxpath + ".svx"
|
||||||
cave.save()
|
cave.save(update_fields=["survex_file"])
|
||||||
cave_svxpath = svxpath
|
cave_svxpath = svxpath
|
||||||
try:
|
try:
|
||||||
fileroot = SurvexFile.objects.get(path=cave_svxpath)
|
fileroot = SurvexFile.objects.get(path=cave_svxpath)
|
||||||
|
|||||||
Reference in New Issue
Block a user