Character count added and tests passing.

Remove sql restriction for count to not be null.
This commit is contained in:
Nicholas Staples
2016-04-15 15:19:58 +01:00
parent 966a662513
commit f681d40366
5 changed files with 74 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import math
from sqlalchemy import (
desc,
func
@@ -47,6 +48,14 @@ def transactional(func):
return commit_or_rollback
def get_character_count_of_content(content, encoding='utf-8'):
return len(content.encode(encoding))
def get_sms_message_count(char_count):
return 1 if char_count <= 160 else math.ceil(float(char_count) / 153)
def dao_get_notification_statistics_for_service(service_id):
return NotificationStatistics.query.filter_by(
service_id=service_id