diff --git a/core/views/statistics.py b/core/views/statistics.py index 5231b31..f56b821 100644 --- a/core/views/statistics.py +++ b/core/views/statistics.py @@ -15,7 +15,50 @@ from troggle.parsers.people import GetPersonExpeditionNameLookup, foreign_friend the status of data inconsistencies """ +def svxfilewild(request, year=None): + """Looks for survexfiles which do not have an associated + wallet, per year + """ + legsbyexpo = [] + addupsurvexlength = 0.0 + addupsurvexlegs = 0 + + if not year: + expos = Expedition.objects.all() + else: + expos = Expedition.objects.filter(year=year) + + for expedition in expos: + survexblocks = expedition.survexblock_set.all() + legsyear = 0 + survexleglength = 0.0 + for survexblock in survexblocks: + survexleglength += survexblock.legslength + legsyear += int(survexblock.legsall) + addupsurvexlength += survexleglength + addupsurvexlegs += legsyear + legsbyexpo.append((expedition, {"nsurvexlegs": legsyear, "survexleglength": survexleglength})) + legsbyexpo.reverse() + svxwild = [] + for expedition in expos: + survexblocks = expedition.survexblock_set.all() + for sb in survexblocks: + # print(f"{sb=}") + if sb.scanswallet == None: + if sb.name != "rootblock": + svxwild.append(sb) + print(f" WILD {sb.survexfile} {sb.date}") + # else: + # print(f" TAME {sb.survexfile}") + + return render(request, "survexfilewild.html", + {"addupsurvexlength": addupsurvexlength / 1000, + "legsbyexpo": legsbyexpo, + "nsurvexlegs": addupsurvexlegs, + "svxwild": svxwild} + ) + def therionissues(request): """Page displaying contents of a file produced during data import""" logname = "therionrefs.log" diff --git a/templates/survexfilewild.html b/templates/survexfilewild.html new file mode 100644 index 0000000..36cfbc3 --- /dev/null +++ b/templates/survexfilewild.html @@ -0,0 +1,44 @@ +{% extends "base.html" %} +{% block title %}Survex files which have no wallets{% endblock %} + +{% block content %} + +

'Wild' Survex files

+ +

These are survex files which have NO ATTACHED WALLET. +
+i.e. they have no *REF line which refers to the wallet holding the raw data for this survey. +

WORK IN PROGRESS + + + +{% for sb in svxwild %} + + + + + + +{% endfor %} +
Survex Blocksdatesurvex filesurveyed length
{{ sb }} {{sb.date }} {{sb.survexfile.path}} {{sb.legslength|floatformat:"1g" }}m
+
+
+ + +{% for legs in legsbyexpo %} + + + + + + +{% endfor %} +
YearSurvex
Survey
Blocks
Survex
Survey Legs
Survex
length(m)
{{legs.0}}{{legs.0.survexblock_set.all|length}}{{legs.1.nsurvexlegs|rjust:"10"|floatformat:"0g"}} {{legs.1.survexleglength|floatformat:"0g"}}
+ + +

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

One Survex Survey Block is one *begin/*end block of data in a survex file. +Some files from other caving clubs may have a convention of using many more blocks per file than we do, e.g. if the +file is exported from other software into survex format. + +{% endblock %} \ No newline at end of file diff --git a/urls.py b/urls.py index 2e13eb8..312df49 100644 --- a/urls.py +++ b/urls.py @@ -192,6 +192,9 @@ trogglepatterns = [ path('survexfile/.err', survex.err, name="err"), path('survexfile/', survex.survexcavesingle, name="survexcavessingle"), + path('survexfilewild', statistics.svxfilewild, name="svxfilewild"), + path('survexfilewild/', statistics.svxfilewild, name="svxfilewild"), + # The survey scans in the wallets. This short-cuts SCANS_URL which is not used anymore and is defunct path('survey_scans/', allscans, name="allscans"), # all the scans in all wallets