diff options
Diffstat (limited to 'core/views/logbooks.py')
-rw-r--r-- | core/views/logbooks.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 003b67f..8b62368 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -16,7 +16,7 @@ from troggle.parsers.imports import import_logbook """These views are for logbook items when they appear in an 'expedition' page and for persons: their individual pages and their perseonexpedition pages. -It uses the global object TROG to hold some cached pages. +It uses the global object TROG to hold some cached pages. USELESS as cache only works single-threaded, single-user. """ todo = """- Fix the get_person_chronology() display bug. @@ -91,17 +91,16 @@ def expedition(request, expeditionname): # print('! - expo {expeditionanme} using cached page') return render(request, "expedition.html", {**ts[expeditionname], "logged_in": logged_in}) - expeditions = Expedition.objects.all() # top menu only, evaluated only when template renders - entries = expo.logbookentry_set.all() - blocks = expo.survexblock_set.all() + entries = expo.logbookentry_set.only('date','title').filter(expedition=expo) + blocks = expo.survexblock_set.only('date','name').filter(expedition=expo).prefetch_related('scanswallet', 'survexfile') dateditems = list(entries) + list(blocks) # evaluates the Django query and hits db dates = sorted(set([item.date for item in dateditems])) - allpersonlogentries = PersonLogEntry.objects.filter(personexpedition__expedition=expo) + allpersonlogentries = PersonLogEntry.objects.prefetch_related('logbook_entry').select_related('personexpedition__expedition').filter(personexpedition__expedition=expo) personexpodays = [] - for personexpedition in expo.personexpedition_set.all(): + for personexpedition in expo.personexpedition_set.all().prefetch_related('person'): expotrips = allpersonlogentries.filter(personexpedition=personexpedition) # lazy expoblocks = blocks.filter(survexpersonrole__personexpedition=personexpedition) @@ -118,6 +117,8 @@ def expedition(request, expeditionname): prow.append(pcell) personexpodays.append({"personexpedition": personexpedition, "personrow": prow, "sortname": personexpedition.person.last_name}) + expeditions = Expedition.objects.only('year') # top menu only, evaluated only when template renders, only need "year" + ts[expeditionname] = { "year": int(expeditionname), "expedition": expo, |