summaryrefslogtreecommitdiffstats
path: root/core/views/logbooks.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-02-27 22:23:24 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2023-02-27 22:23:24 +0000
commit5c3927c25d51e907a176203431be3b23cdcfd8ae (patch)
treeedc1757cedc791dd549392a5f0afb766e9f2a264 /core/views/logbooks.py
parent154722f765d99c014ddd43f8cbce47799bdc3cce (diff)
downloadtroggle-5c3927c25d51e907a176203431be3b23cdcfd8ae.tar.gz
troggle-5c3927c25d51e907a176203431be3b23cdcfd8ae.tar.bz2
troggle-5c3927c25d51e907a176203431be3b23cdcfd8ae.zip
all working, queries improved, date-ordered.
Diffstat (limited to 'core/views/logbooks.py')
-rw-r--r--core/views/logbooks.py23
1 files changed, 7 insertions, 16 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 37d6aa9..626153c 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -1,10 +1,10 @@
-
+from django.db.models import Q
from django.shortcuts import render
from django.views.generic.list import ListView
import troggle.settings as settings
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry
-from troggle.core.models.survex import SurvexBlock
+from troggle.core.models.survex import SurvexBlock, SurvexFile
from troggle.core.models.troggle import Expedition, Person
from troggle.core.models.wallets import Wallet
from troggle.core.utils import TROG
@@ -212,22 +212,13 @@ def logbookentry(request, date, slug):
if this_logbookentry:
if len(this_logbookentry) > 1:
+ # BUG
return render(request, "object_list.html", {"object_list": this_logbookentry})
else:
- wallets = set()
- allwallets = Wallet.objects.all()
- refwallets = allwallets.filter(survexblock__date=date)
- for r in refwallets:
- wallets.add(r)
-
- # Note that w.year() only works for wallets which have a valid JSON file existing
- # 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)
-
- svxothers = SurvexBlock.objects.filter(date=date)
+ # https://stackoverflow.com/questions/739776/how-do-i-do-an-or-filter-in-a-django-query
+ wallets = Wallet.objects.filter(Q(survexblock__date=date) | Q(walletdate=date)).distinct()
+ svxothers = SurvexFile.objects.filter(survexblock__date=date).distinct()
+
this_logbookentry = this_logbookentry[0]
# This is the only page that uses next_.. and prev_..
# and it is calculated on the fly in the model