From 9a3651ed8b768aceec71ea0023324bf1628c564f Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 21 Jul 2025 19:24:14 +0200 Subject: [PATCH] fixed bug from people who did not turn up, optimised parsing a bit --- core/models/troggle.py | 10 ++++++++-- parsers/caves.py | 18 ++++++++++-------- templates/notablepersons.html | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/models/troggle.py b/core/models/troggle.py index d34e145..a9103bb 100644 --- a/core/models/troggle.py +++ b/core/models/troggle.py @@ -144,10 +144,16 @@ class Person(TroggleModel): return sum([personexpedition.surveyedleglength() for personexpedition in self.personexpedition_set.all()]) def first(self): - return self.personexpedition_set.order_by("-expedition")[0] + if self.personexpedition_set.order_by("-expedition"): + return self.personexpedition_set.order_by("-expedition")[0] + else: + return None def last(self): - return self.personexpedition_set.order_by("expedition")[0] + if self.personexpedition_set.order_by("expedition"): + return self.personexpedition_set.order_by("expedition")[0] + else: + return None # moved from personexpedition def name(self): diff --git a/parsers/caves.py b/parsers/caves.py index b8430ea..e1918c7 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -680,22 +680,24 @@ def read_cave(filename, mvf=None, cave=None): else: # print(f"eslug {eslug} looking up entrance ") try: - entrance_count = Entrance.objects.filter(slug=eslug).count() + entrance_e = Entrance.objects.filter(slug=eslug) except: message = f"! Fail entrance count {eslug}. {entrance_count=}" print(message) - if entrance_count == 1: - entrance = Entrance.objects.get(slug=eslug) + if entrance_e.count() == 1: + entrance = entrance_e[0] + # entrance = Entrance.objects.get(slug=eslug) entrances_xslug[eslug] = entrance else: - message = f"! Entrance count {entrance_count=} for {eslug}. " + message = f"! Entrance count {entrance_e.count()=} for {eslug}. " print(message) eslug = eslug[:-1] + eslug[-1].upper() - entrance_count = Entrance.objects.filter(slug=eslug).count() - message = f"! Entrance count {entrance_count=} for uppercase variant {eslug}. " + entrance_e = Entrance.objects.filter(slug=eslug) + message = f"! Entrance count {entrance_e.count()=} for uppercase variant {eslug}. " print(message) - if entrance_count == 1: - entrance = Entrance.objects.get(slug=eslug) + if entrance_e.count() == 1: + entrance = entrance_e[0] + # entrance = Entrance.objects.get(slug=eslug) entrances_xslug[eslug] = entrance message = f"! Warning entrance loading {eslug} only exists as upper case variant " DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}_cave_edit/") diff --git a/templates/notablepersons.html b/templates/notablepersons.html index 4485dd9..1149686 100644 --- a/templates/notablepersons.html +++ b/templates/notablepersons.html @@ -19,7 +19,7 @@ {% endfor %}

This is based purely on attendance, not on activities, surveying or usefulness of any kind. -But as Woody Allen said: "90% of success is just turning up". +But as Woody Allen said: "80% of success is showing up". This is mostly people who have been within the past three years, with an additional bias for number of attendances since 1976. The metric is just a geometric "recency" (1/2 for attending last year, 1/3 for the year before, etc., added up.) The display cuttoff is 1/3 so if you came just once, three years ago, you are on the list.