Browse Source

Check if probes_sent and probes_received exist before using them

Baptiste Jonglez 10 years ago
parent
commit
2b3c885ad7
1 changed files with 6 additions and 1 deletions
  1. 6 1
      templates/results.html

+ 6 - 1
templates/results.html

@@ -25,14 +25,19 @@
   {% endif %}
   {%- endmacro %}
   {% for r in results %}
+  {% if r.probes_sent is not none() and r.probes_received is not none() %}
   {% set packetloss = (100 * (r.probes_sent - r.probes_received) / r.probes_sent) %}
+  {% endif %}
   <tr>
     <td>{% if r.avgrtt is not none() %}{{ r.avgrtt|round(2) }} ms{% endif %}</td>
     <td>{% if r.jitter is not none() %}{{ r.jitter|round(2) }} ms{% endif %}</td>
-    <td><span class={{ color(packetloss) }}>
+    <td>
+      {% if r.probes_sent is not none() and r.probes_received is not none() %}
+      <span class={{ color(packetloss) }}>
         {{ packetloss|round(2) }}%
       </span>
       (<span class={{ color(packetloss) }}>{{ r.probes_sent - r.probes_received }}</span>/{{ r.probes_sent }})
+      {% endif %}
     </td>
     <td>{{ r.participant.name }}
       {% if r.participant.country is not none() %}