New dao and endpoints to create and update service data retention.

This commit is contained in:
Rebecca Law
2018-07-11 17:02:49 +01:00
parent e4cc90e585
commit e2a1dfeb31
7 changed files with 302 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
from datetime import datetime
from app import db
from app.dao.dao_utils import transactional
from app.models import ServiceDataRetention
def get_service_data_retention(service_id):
data_retention = ServiceDataRetention.query.filter_by(service_id=service_id).all()
return data_retention
@transactional
def insert_service_data_retention(service_id, notification_type, days_of_retention):
new_data_retention = ServiceDataRetention(service_id=service_id,
notification_type=notification_type,
days_of_retention=days_of_retention)
db.session.add(new_data_retention)
return new_data_retention
@transactional
def update_service_data_retention(service_data_retention_id, service_id, days_of_retention):
updated_count = ServiceDataRetention.query.filter(
ServiceDataRetention.id == service_data_retention_id,
ServiceDataRetention.service_id == service_id
).update(
{
"days_of_retention": days_of_retention,
"updated_at": datetime.utcnow()
}
)
return updated_count