summaryrefslogtreecommitdiffstats
path: root/core/views/logbooks.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2022-12-19 20:13:26 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2022-12-19 20:13:26 +0000
commitbb14c94ab10cbd279586c97822372bba8375b67b (patch)
tree01b251b8290e8f5a6b2784a25ca71157cbc21f88 /core/views/logbooks.py
parent7e9bb737771bb031d7db7864a5267b75da8e08c0 (diff)
downloadtroggle-bb14c94ab10cbd279586c97822372bba8375b67b.tar.gz
troggle-bb14c94ab10cbd279586c97822372bba8375b67b.tar.bz2
troggle-bb14c94ab10cbd279586c97822372bba8375b67b.zip
Updates to make 2018 blog merge work (faster)
Diffstat (limited to 'core/views/logbooks.py')
-rw-r--r--core/views/logbooks.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 517a48b..52e2d11 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -1,4 +1,5 @@
import datetime
+import time
import os.path
import re
@@ -186,24 +187,26 @@ def personexpedition(request, first_name='', last_name='', year=''):
def logbookentry(request, date, slug):
- this_logbookentry = LogbookEntry.objects.filter(date=date, slug=slug)
+ # start = time.time()
+ trips = LogbookEntry.objects.filter(date=date) # all the trips not just this one
+ this_logbookentry = trips.filter(date=date, slug=slug)
if this_logbookentry:
if len(this_logbookentry)>1:
return render(request, 'object_list.html',{'object_list':this_logbookentry})
else:
- trips = LogbookEntry.objects.filter(date=date)
wallets = set()
- refwallets = Wallet.objects.filter(survexblock__date=date)
+ allwallets = Wallet.objects.all()
+ refwallets = allwallets.filter(survexblock__date=date)
for r in refwallets:
wallets.add(r)
-
- allwallets = Wallet.objects.all()
+
# Note that w.year() only works for wallets which have a valid JSON file existing
- for w in allwallets:
- if w.date() == date:
- wallets.add(w)
-
+ # This is very slow with a big lag as w.date() is a computed field
+ # Noticably slow with WSL2 and NTFS filesystem, even with caching as walletdate.
+ jwallets = allwallets.filter(walletdate=date)
+ for j in jwallets:
+ wallets.add(j)
thisexpo = this_expedition = Expedition.objects.get(year=int(date[0:4]))
if thisexpo:
expeditionday = thisexpo.get_expedition_day(date)
@@ -214,6 +217,8 @@ def logbookentry(request, date, slug):
this_logbookentry=this_logbookentry[0]
# This is the only page that uses presontrip_next and persontrip_prev
# and it is calculated on the fly in the model
+ # duration = time.time()-start
+ # print(f"--- Render after {duration:.2f} seconds")
return render(request, 'logbookentry.html',
{'logbookentry': this_logbookentry, 'trips': trips, 'svxothers': svxothers, 'wallets': wallets})
else: