Opened 6 years ago

Closed 6 years ago

#1560 closed defect (fixed)

ZeroDivisionError in sitescripts.stats.bin.pagegenerator

Reported by: trev Assignee: trev
Priority: P1 Milestone:
Module: Infrastructure Keywords:
Cc: Blocked By:
Blocking: Platform: Unknown
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):



Our stats server was producing errors when generating pages lately:

  File "/opt/sitescripts/sitescripts/stats/template/fileStats.html", line 141, in top-level template code
    {{row(field.title, data[].True, params, chart=False,
  File "/opt/sitescripts/sitescripts/stats/template/fileStats.html", line 93, in template
    <td align="right">{{(value.bandwidth / params.totalbandwidth * 100)|round(precision=1)}}%</td>
ZeroDivisionError: division by zero

Apparently, params.totalbandwidth is zero. We didn't consider that scenario when the script was created - there must be at least one hit, otherwise no statistics would exist for that file. Here that hit apparently produced zero bandwidth which is highly unusual but not impossible.

What to change

We should guard against division by zero here, similarly to how it is done elsewhere.

Change History (2)

comment:1 Changed 6 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 6 years ago by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.