forked from expo/troggle
Updates to make 2018 blog merge work (faster)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user