mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Adds notification stats update into the callback process
- when a provider callback occurs and we update the status of the notification, also update the statistics table Adds: - Mapping object to the clients to handle mapping to various states from the response codes, this replaces the map. - query lookup in the DAO to get the query based on response type / template type Tests around rest class and dao to check correct updating of stats Missing: - multiple client callbacks will keep incrementing the counts of success/failure. This edge case needs to be handle in a future story.
This commit is contained in:
@@ -13,6 +13,11 @@ class Client(object):
|
||||
pass
|
||||
|
||||
|
||||
STATISTICS_REQUESTED = 'requested'
|
||||
STATISTICS_DELIVERED = 'delivered'
|
||||
STATISTICS_FAILURE = 'failure'
|
||||
|
||||
|
||||
class ClientResponse:
|
||||
def __init__(self):
|
||||
self.__response_model__ = None
|
||||
@@ -24,7 +29,6 @@ class ClientResponse:
|
||||
return self.response_code_to_object(response_code)['message']
|
||||
|
||||
def response_code_to_notification_status(self, response_code):
|
||||
print(response_code)
|
||||
return self.response_code_to_object(response_code)['notification_status']
|
||||
|
||||
def response_code_to_notification_statistics_status(self, response_code):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import boto3
|
||||
from flask import current_app
|
||||
from monotonic import monotonic
|
||||
from app.clients import ClientResponse
|
||||
from app.clients import ClientResponse, STATISTICS_DELIVERED, STATISTICS_FAILURE
|
||||
from app.clients.email import (EmailClientException, EmailClient)
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ class AwsSesResponses(ClientResponse):
|
||||
"message": 'Bounced',
|
||||
"success": False,
|
||||
"notification_status": 'bounce',
|
||||
"notification_statistics_status": 'failed'
|
||||
"notification_statistics_status": STATISTICS_FAILURE
|
||||
},
|
||||
'Delivery': {
|
||||
"message": 'Delivered',
|
||||
"success": True,
|
||||
"notification_status": 'delivered',
|
||||
"notification_statistics_status": 'delivered'
|
||||
"notification_statistics_status": STATISTICS_DELIVERED
|
||||
},
|
||||
'Complaint': {
|
||||
"message": 'Complaint',
|
||||
"success": False,
|
||||
"notification_status": 'complaint',
|
||||
"notification_statistics_status": 'failed'
|
||||
"notification_statistics_status": STATISTICS_FAILURE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from app.clients.sms import (
|
||||
)
|
||||
from flask import current_app
|
||||
from requests import request, RequestException, HTTPError
|
||||
from app.clients import ClientResponse
|
||||
from app.clients import ClientResponse, STATISTICS_DELIVERED, STATISTICS_FAILURE
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -17,14 +17,14 @@ class FiretextResponses(ClientResponse):
|
||||
self.__response_model__ = {
|
||||
'0': {
|
||||
"message": 'Delivered',
|
||||
"notification_statistics_status": 'delivered',
|
||||
"notification_statistics_status": STATISTICS_DELIVERED,
|
||||
"success": True,
|
||||
"notification_status": 'delivered'
|
||||
},
|
||||
'1': {
|
||||
"message": 'Declined',
|
||||
"success": False,
|
||||
"notification_statistics_status": 'failed',
|
||||
"notification_statistics_status": STATISTICS_FAILURE,
|
||||
"notification_status": 'failed'
|
||||
},
|
||||
'2': {
|
||||
|
||||
Reference in New Issue
Block a user