From c9931fd45eaa0b05d1bce37d471e873b0955c125 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 18 Apr 2022 23:33:04 +0300 Subject: [PATCH] survey legs calc fixed --- core/views/statistics.py | 9 ++++----- templates/statistics.html | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/views/statistics.py b/core/views/statistics.py index 02cbd43..9e7ff81 100644 --- a/core/views/statistics.py +++ b/core/views/statistics.py @@ -130,22 +130,21 @@ def stats(request): legsbyexpo = [ ] addupsurvexlength = 0 + addupsurvexlegs = 0 for expedition in Expedition.objects.all(): survexblocks = expedition.survexblock_set.all() legsyear=0 survexleglength = 0.0 for survexblock in survexblocks: survexleglength += survexblock.legslength - try: - legsyear += int(survexblock.legsall) - except: - pass + legsyear += int(survexblock.legsall) addupsurvexlength += survexleglength + addupsurvexlegs += legsyear legsbyexpo.append((expedition, {"nsurvexlegs": "{:,}".format(legsyear), "survexleglength":"{:,.0f}".format(survexleglength)})) legsbyexpo.reverse() - renderDict = {**statsDict, **{ "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax + renderDict = {**statsDict, **{ "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo, "nsurvexlegs":addupsurvexlegs }} # new syntax return render(request,'statistics.html', renderDict) def dataissues(request): diff --git a/templates/statistics.html b/templates/statistics.html index f4b95e1..02a8d5c 100644 --- a/templates/statistics.html +++ b/templates/statistics.html @@ -7,12 +7,12 @@

{{ expoCount }} expeditions: {{ personCount }} people, {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries. -

Number of survey legs: {{nsurvexlegs}} «Removed from model, needs calculating..»
+

Number of survey legs: {{nsurvexlegs}}
Total length: {{addupsurvexlength|stringformat:".1f"}} km adding up the total for each year.

These are uncorrected tape lengths which include pitches and duplicates but exclude splays or surface-surveys.

-This is work in progress (March 2021). +This is work in progress (April 2022).
YearSurvex
Survey
Blocks
Survex
Survey Legs
Total length
(m)