2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-18 15:37:12 +00:00

fixed bug from people who did not turn up, optimised parsing a bit

This commit is contained in:
2025-07-21 19:24:14 +02:00
parent b5540fd543
commit 9a3651ed8b
3 changed files with 19 additions and 11 deletions

View File

@@ -144,10 +144,16 @@ class Person(TroggleModel):
return sum([personexpedition.surveyedleglength() for personexpedition in self.personexpedition_set.all()]) return sum([personexpedition.surveyedleglength() for personexpedition in self.personexpedition_set.all()])
def first(self): 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): 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 # moved from personexpedition
def name(self): def name(self):

View File

@@ -680,22 +680,24 @@ def read_cave(filename, mvf=None, cave=None):
else: else:
# print(f"eslug {eslug} looking up entrance ") # print(f"eslug {eslug} looking up entrance ")
try: try:
entrance_count = Entrance.objects.filter(slug=eslug).count() entrance_e = Entrance.objects.filter(slug=eslug)
except: except:
message = f"! Fail entrance count {eslug}. {entrance_count=}" message = f"! Fail entrance count {eslug}. {entrance_count=}"
print(message) print(message)
if entrance_count == 1: if entrance_e.count() == 1:
entrance = Entrance.objects.get(slug=eslug) entrance = entrance_e[0]
# entrance = Entrance.objects.get(slug=eslug)
entrances_xslug[eslug] = entrance entrances_xslug[eslug] = entrance
else: else:
message = f"! Entrance count {entrance_count=} for {eslug}. " message = f"! Entrance count {entrance_e.count()=} for {eslug}. "
print(message) print(message)
eslug = eslug[:-1] + eslug[-1].upper() eslug = eslug[:-1] + eslug[-1].upper()
entrance_count = Entrance.objects.filter(slug=eslug).count() entrance_e = Entrance.objects.filter(slug=eslug)
message = f"! Entrance count {entrance_count=} for uppercase variant {eslug}. " message = f"! Entrance count {entrance_e.count()=} for uppercase variant {eslug}. "
print(message) print(message)
if entrance_count == 1: if entrance_e.count() == 1:
entrance = Entrance.objects.get(slug=eslug) entrance = entrance_e[0]
# entrance = Entrance.objects.get(slug=eslug)
entrances_xslug[eslug] = entrance entrances_xslug[eslug] = entrance
message = f"! Warning entrance loading {eslug} only exists as upper case variant " 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/") DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}_cave_edit/")

View File

@@ -19,7 +19,7 @@
{% endfor %} {% endfor %}
</table> </table>
<p>This is based purely on attendance, not on activities, surveying or usefulness of any kind. <p>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. 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 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. The display cuttoff is 1/3 so if you came just once, three years ago, you are on the list.