mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
We found a problem with the report tasks that populate the fact tables (or statistic tables). It is possible that the notification status can change for notifications after 4 days.
This PR updates those queries to look in either Notification or NotificationHistory. Since the data does not exist in both tables at the same time we can do with and not worry about the data retention. The query will iterate over each service, then each notification type and query the data if no results then try the history table.
This commit is contained in:
@@ -18,7 +18,10 @@ from app.dao.fact_notification_status_dao import (
|
||||
from app.models import FactNotificationStatus, KEY_TYPE_TEST, KEY_TYPE_TEAM, EMAIL_TYPE, SMS_TYPE, LETTER_TYPE
|
||||
from freezegun import freeze_time
|
||||
|
||||
from tests.app.db import create_notification, create_service, create_template, create_ft_notification_status, create_job
|
||||
from tests.app.db import (
|
||||
create_notification, create_service, create_template, create_ft_notification_status,
|
||||
create_job, create_notification_history
|
||||
)
|
||||
|
||||
|
||||
def test_update_fact_notification_status(notify_db_session):
|
||||
@@ -31,8 +34,9 @@ def test_update_fact_notification_status(notify_db_session):
|
||||
|
||||
create_notification(template=first_template, status='delivered')
|
||||
create_notification(template=first_template, created_at=datetime.utcnow() - timedelta(days=1))
|
||||
create_notification(template=second_template, status='temporary-failure')
|
||||
create_notification(template=second_template, created_at=datetime.utcnow() - timedelta(days=1))
|
||||
# simulate a service with data retention - data has been moved to history and does not exist in notifications
|
||||
create_notification_history(template=second_template, status='temporary-failure')
|
||||
create_notification_history(template=second_template, created_at=datetime.utcnow() - timedelta(days=1))
|
||||
create_notification(template=third_template, status='created')
|
||||
create_notification(template=third_template, created_at=datetime.utcnow() - timedelta(days=1))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user