survey legs calc fixed

This commit is contained in:
Philip Sargent
2022-04-18 23:33:04 +03:00
parent 3813b21dcf
commit c9931fd45e
2 changed files with 6 additions and 7 deletions

View File

@@ -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):