mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
When creating a notification don't create a history row if:
1) research mode service 2) test mode key Stop test data getting into history and subsequently into stats and so on.
This commit is contained in:
@@ -130,9 +130,17 @@ def dao_create_notification(notification):
|
||||
if not notification.status:
|
||||
notification.status = 'created'
|
||||
|
||||
notification_history = NotificationHistory.from_notification(notification)
|
||||
db.session.add(notification)
|
||||
db.session.add(notification_history)
|
||||
if _should_record_notification_in_history_table(notification):
|
||||
db.session.add(NotificationHistory.from_notification(notification))
|
||||
|
||||
|
||||
def _should_record_notification_in_history_table(notification):
|
||||
if notification.api_key_id and notification.key_type == KEY_TYPE_TEST:
|
||||
return False
|
||||
if notification.service.research_mode:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _decide_permanent_temporary_failure(current_status, status):
|
||||
@@ -192,6 +200,7 @@ def dao_update_notification(notification):
|
||||
notification_history = NotificationHistory.query.get(notification.id)
|
||||
notification_history.update_from_notification(notification)
|
||||
db.session.add(notification)
|
||||
db.session.add(notification_history)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user