summaryrefslogtreecommitdiffstats
path: root/core/views_statistics.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/views_statistics.py')
-rw-r--r--core/views_statistics.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/core/views_statistics.py b/core/views_statistics.py
index 86ee064..bd71a1f 100644
--- a/core/views_statistics.py
+++ b/core/views_statistics.py
@@ -82,19 +82,24 @@ def stats(request):
statsDict['caveCount'] = "{:,}".format(Cave.objects.count())
statsDict['personCount'] = "{:,}".format(Person.objects.count())
statsDict['logbookEntryCount'] = "{:,}".format(LogbookEntry.objects.count())
-
- blockroots = SurvexBlock.objects.filter(name="rootblock")
- if len(blockroots)>1:
- print(" ! more than one root survexblock {}".format(len(blockroots)))
- for sbr in blockroots:
- print("{} {} {} {}".format(sbr.id, sbr.name, sbr.text, sbr.date))
- sbr = blockroots[0]
- totalsurvexlength = sbr.totalleglength
try:
- nimportlegs = int(sbr.text)
+ blockroots = SurvexBlock.objects.filter(name="rootblock")
+ if len(blockroots)>1:
+ print(" ! more than one root survexblock {}".format(len(blockroots)))
+ for sbr in blockroots:
+ print("{} {} {} {}".format(sbr.id, sbr.name, sbr.legsall, sbr.date))
+ sbr = blockroots[0]
+ totalsurvexlength = sbr.totalleglength
+ nimportlegs = sbr.legsall
except:
- print("{} {} {} {}".format(sbr.id, sbr.name, sbr.text, sbr.date))
+ # if no files yet imported into database
+ #survexfile = models_survex.SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
+ #survexblockdummy = models_survex.SurvexBlock(name="dummy", survexpath="", cave=None, survexfile=survexfile,
+ #legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
+ #sbr = survexblockdummy
+ totalsurvexlength = 0.0
nimportlegs = -1
+ print("{} {} {} {}".format(sbr.id, sbr.name, sbr.legsall, sbr.date))
legsbyexpo = [ ]
addupsurvexlength = 0
@@ -105,14 +110,14 @@ def stats(request):
for survexblock in survexblocks:
survexleglength += survexblock.totalleglength
try:
- legsyear += int(survexblock.text)
+ legsyear += int(survexblock.legsall)
except:
pass
addupsurvexlength += survexleglength
legsbyexpo.append((expedition, {"nsurvexlegs": "{:,}".format(legsyear),
"survexleglength":"{:,.0f}".format(survexleglength)}))
legsbyexpo.reverse()
- survexlegs = SurvexLeg.objects.all()
+ #survexlegs = SurvexLeg.objects.all()
renderDict = {**statsDict, **{ "nsurvexlegs": "{:,}".format(nimportlegs), "totalsurvexlength":totalsurvexlength/1000, "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax
return render(request,'statistics.html', renderDict)