person attribution of surveyed length working

This commit is contained in:
Philip Sargent
2020-07-06 01:24:43 +01:00
parent 3f9971d2ee
commit 8530b0643d
9 changed files with 70 additions and 37 deletions

View File

@@ -12,6 +12,7 @@
</h1>
<p>{{message}}</p>
<p>{{personexpedition.surveyedleglength|stringformat:".1f"}} m surveyed this year.</p>
<p><b>Other years:</b>
{% for otherpersonexpedition in personexpedition.person.personexpedition_set.all %}
@@ -26,32 +27,48 @@
<h3>Table of all trips and surveys aligned by date</h3>
<div>
<table class="survexcontibutions">
<tr><th>Date</th><th colspan="2">Trips</th><th colspan="2">Surveys</th></tr>
<tr><th>Date</th><th colspan="2">Trips</th><th colspan="3">Surveys</th></tr>
{% for persondate in personchronology %}
<tr>
<td class="date">{{persondate.0}}</td>
{% if persondate.1 %}
<td class="trip"><a href="{{ persondate.1.logbook_entry.get_absolute_url }}">{{persondate.1.logbook_entry.title|safe}}</a></td>
<td width="35%" class="trip"><a href="{{ persondate.1.logbook_entry.get_absolute_url }}">{{persondate.1.logbook_entry.title|safe}}</a></td>
<td><a href="{{ persondate.1.logbook_entry.cave.get_absolute_url }}">{{persondate.1.place|safe}}</a></td>
{% else %}
<td colspan="2"> </td>
{% endif %}
{% if persondate.2 %}
<td class="survexblock"><a href="{% url "svx" persondate.2.survexfile.path %}">{{persondate.2}}</a></td>
<td class="roles">
<td class="survexblock"><a href="{% url "svx" persondate.2.survexfile.path %}">{{persondate.2.name}}</a></td>
<td class="roles" style="padding-right: 3px; text-align:right">
{% for survexpersonrole in persondate.2.survexpersonrole_set.all %}
{{survexpersonrole.nrole}}
{% endfor %}
</td>
<td style="text-align:right">
{{persondate.2.legslength|stringformat:".1f"}} m
</td>
{% else %}
<td colspan="2"> </td>
<td colspan="3"> </td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
<div style="color: slategray; background-color:lightcyan">
<p>Horrible bug here but only when there is more than one survex block per day,
e.g. see <a href="/personexpedition/Wookey/1999">Wookey 1999</a> where there are 3 eiscream survex blocks on 5th August.
it duplicates the entry but gets it wrong. The length from the first block is displayed twice but there should be 3 rows: eiscream, eiscream2, eiscream3.
<p>Fortunately it is <b>just this display on this page which is wrong</b>: no bad calculations get into the database.
<p>The interaction of django database query idioms with <a href="https://docs.djangoproject.com/en/1.11/ref/templates/api/">django HTML templating language</a> is a bit impenetrable here. <br>
- The template is in <var>troggle/templates/personexpedition.html</var>
<br>
- The code is in function <var>personexpedition()</var> which calls
<var>GetPersonChronology()</var> in <var>troggle/core/views_logbooks.py</var>
<br>
- the connection between the two is made in the URL resolver in <var>troggle/urls.py</var>
<p>To be fixed!
</div>
{% endblock %}

View File

@@ -5,19 +5,19 @@
{% block content %}
<h2>Notable expoers</h2>
<h2>Notably Recent Expoers</h2>
<table class="searchable">
<tr><th>Person</th><th>First</th><th>Last</th><th>Notability</th></tr>
<tr><th>Person</th><th>First</th><th>Last</th><th>Recency</th></tr>
{% for person in notablepersons|dictsortreversed:"notability" %}
<tr>
<td><a href="{{ person.get_absolute_url }}">{{person|wiki_to_html_short}}</a></td>
<td><a href="{{ person.first.get_absolute_url }}">{{ person.first.expedition.year }}</a></td>
<td><a href="{{ person.last.get_absolute_url }}">{{ person.last.expedition.year }}</a></td>
<td>{{person.notability|floatformat:2}}</td>
<td style="text-align:right">{{person.notability|floatformat:2}}</td>
</tr>
{% endfor %}
</table>
<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". It should really be called "Notably recent expoers" as the metric is just a geometric "recency" (1/2 for attending last year, 1/3 for the year before, etc., added up. Display cuttoff is 1/3.).
<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". 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 display cuttoff is 1/3 so if you came just once, three years ago, you are on the list.
<h2>All expoers</h2>
@@ -33,7 +33,7 @@
<td><a href="{{ person.get_absolute_url }}">{{person|wiki_to_html_short}}</a></td>
<td><a href="{{ person.first.get_absolute_url }}">{{person.first.expedition.year}}</a></td>
<td><a href="{{ person.last.get_absolute_url }}">{{person.last.expedition.year}}</a></td>
<td></td>
<td style="text-align:right">{{person.surveyedleglength|stringformat:".0f"}} m </td>
</tr>
{% endfor %}
</table>

View File

@@ -48,7 +48,7 @@
</td>
<td>
{% for personrole in survexblock.personrole_set.all %}
{% for personrole in survexblock.survexpersonrole_set.all %}
{% if personrole.personexpedition %}
<a href="{{personrole.personexpedition.get_absolute_url}}">{{personrole.personname}}</a>
{% else %}