mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Fix division by zero
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import dateutil
|
import dateutil
|
||||||
from flask import (Flask, session, Markup, escape, render_template, make_response)
|
from flask import (Flask, session, Markup, escape, render_template, make_response, current_app)
|
||||||
from flask._compat import string_types
|
from flask._compat import string_types
|
||||||
from flask_login import LoginManager
|
from flask_login import LoginManager
|
||||||
from flask_wtf import CsrfProtect
|
from flask_wtf import CsrfProtect
|
||||||
@@ -206,4 +206,6 @@ def register_errorhandlers(application):
|
|||||||
|
|
||||||
@application.errorhandler(Exception)
|
@application.errorhandler(Exception)
|
||||||
def handle_bad_request(error):
|
def handle_bad_request(error):
|
||||||
|
if current_app.config.get('DEBUG', None):
|
||||||
|
raise error
|
||||||
return _error_response(500)
|
return _error_response(500)
|
||||||
|
|||||||
@@ -49,8 +49,10 @@ def expand_statistics(statistics, danger_zone=25):
|
|||||||
today = statistics[0]
|
today = statistics[0]
|
||||||
|
|
||||||
today.update({
|
today.update({
|
||||||
'emails_failure_rate': int(today['emails_error'] / today['emails_requested'] * 100),
|
'emails_failure_rate':
|
||||||
'sms_failure_rate': int(today['sms_error'] / today['sms_requested'] * 100)
|
int(today['emails_error'] / today['emails_requested'] * 100) if today['emails_requested'] else 0,
|
||||||
|
'sms_failure_rate':
|
||||||
|
int(today['sms_error'] / today['sms_requested'] * 100) if today['sms_requested'] else 0
|
||||||
})
|
})
|
||||||
|
|
||||||
today.update({
|
today.update({
|
||||||
|
|||||||
Reference in New Issue
Block a user