mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 07:28:45 +00:00
cache expeditions - trivial
This commit is contained in:
@@ -843,26 +843,16 @@ class LoadingSurvex:
|
||||
|
||||
def get_expo_from_year(self, year, line, survexblock):
|
||||
# cacheing to save DB query on every block
|
||||
if year in self.expos:
|
||||
expo = self.expos[year]
|
||||
# Minimize ORM calls: cache all expeditions by year on first use
|
||||
if not hasattr(self, '_expedition_cache'):
|
||||
self._expedition_cache = {e.year: e for e in Expedition.objects.all()}
|
||||
if year in self._expedition_cache:
|
||||
expo = self._expedition_cache[year]
|
||||
else:
|
||||
expeditions = Expedition.objects.filter(year=year)
|
||||
if len(expeditions) > 1:
|
||||
message = (
|
||||
f"! More than one expedition in year {year} '{line}' ({survexblock}) {survexblock.survexfile.path}"
|
||||
)
|
||||
print(self.insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
if expeditions:
|
||||
expo = expeditions[0]
|
||||
self.expos[year] = expo
|
||||
else:
|
||||
expo = Expedition.objects.get(year="1976")
|
||||
message = f"! DATE INCORRECT. There is no expedition for the year {year}. {survexblock.survexfile.path} ({survexblock}) - set to 1976."
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser='survex', message=message, url=None, sb=(survexblock.survexfile.path))
|
||||
expo = self._expedition_cache.get("1976")
|
||||
return expo
|
||||
|
||||
def LoadSurvexDate(self, survexblock, line):
|
||||
|
||||
Reference in New Issue
Block a user