Fixed typo and moved the sms free limit into the config.

This commit is contained in:
Martyn Inglis
2017-06-01 17:04:41 +01:00
parent 52326539d6
commit e236cc4cbe
2 changed files with 7 additions and 6 deletions
+2
View File
@@ -59,6 +59,8 @@ class Config(object):
ACTIVITY_STATS_LIMIT_DAYS = 7 ACTIVITY_STATS_LIMIT_DAYS = 7
TEST_MESSAGE_FILENAME = 'Test message' TEST_MESSAGE_FILENAME = 'Test message'
SMS_FREE_TIER_AMOUNT = 250000
STATSD_ENABLED = False STATSD_ENABLED = False
STATSD_HOST = "statsd.hostedgraphite.com" STATSD_HOST = "statsd.hostedgraphite.com"
STATSD_PORT = 8125 STATSD_PORT = 8125
+5 -6
View File
@@ -2,6 +2,7 @@ from datetime import datetime
from functools import partial from functools import partial
from flask import ( from flask import (
render_template, render_template,
current_app,
url_for, url_for,
session, session,
jsonify, jsonify,
@@ -186,7 +187,7 @@ def get_dashboard_partials(service_id):
'has_jobs': bool(immediate_jobs), 'has_jobs': bool(immediate_jobs),
'usage': render_template( 'usage': render_template(
'views/dashboard/_usage.html', 'views/dashboard/_usage.html',
**calculate_fee_tier_usage(service_api_client.get_yearly_sms_unit_count_and_cost( **calculate_free_tier_usage(service_api_client.get_yearly_sms_unit_count_and_cost(
service_id, service_id,
get_current_financial_year(), get_current_financial_year(),
)) ))
@@ -201,9 +202,8 @@ def get_dashboard_totals(statistics):
return statistics return statistics
def calculate_fee_tier_usage(usage): def calculate_free_tier_usage(usage):
# TODO: Don't hardcode these - get em from the API sms_free_allowance = current_app.config['SMS_FREE_TIER_AMOUNT']
sms_free_allowance = 250000
return({ return({
'sms_chargeable': max(0, usage['billable_sms_units'] - sms_free_allowance), 'sms_chargeable': max(0, usage['billable_sms_units'] - sms_free_allowance),
@@ -214,8 +214,7 @@ def calculate_fee_tier_usage(usage):
def calculate_usage(usage): def calculate_usage(usage):
# TODO: Don't hardcode these - get em from the API sms_free_allowance = current_app.config['SMS_FREE_TIER_AMOUNT']
sms_free_allowance = 250000
sms_rate = 0 if len(usage) == 0 else usage[0].get("rate", 0) sms_rate = 0 if len(usage) == 0 else usage[0].get("rate", 0)
sms_sent = get_sum_billing_units(breakdown for breakdown in usage if breakdown['notification_type'] == 'sms') sms_sent = get_sum_billing_units(breakdown for breakdown in usage if breakdown['notification_type'] == 'sms')