more code review feedback

This commit is contained in:
Kenneth Kehl
2024-12-20 08:09:19 -08:00
parent a77343ebc7
commit 3c0621f472
22 changed files with 125 additions and 133 deletions

View File

@@ -20,15 +20,15 @@ def dao_get_inbound_sms_for_service(
):
q = (
select(InboundSms)
.filter(InboundSms.service_id == service_id)
.where(InboundSms.service_id == service_id)
.order_by(InboundSms.created_at.desc())
)
if limit_days is not None:
start_date = midnight_n_days_ago(limit_days)
q = q.filter(InboundSms.created_at >= start_date)
q = q.where(InboundSms.created_at >= start_date)
if user_number:
q = q.filter(InboundSms.user_number == user_number)
q = q.where(InboundSms.user_number == user_number)
if limit:
q = q.limit(limit)
@@ -47,7 +47,7 @@ def dao_get_paginated_inbound_sms_for_service_for_public_api(
if older_than:
older_than_created_at = (
db.session.query(InboundSms.created_at)
.filter(InboundSms.id == older_than)
.where(InboundSms.id == older_than)
.scalar_subquery()
)
filters.append(InboundSms.created_at < older_than_created_at)
@@ -72,7 +72,7 @@ def dao_count_inbound_sms_for_service(service_id, limit_days):
stmt = (
select(func.count())
.select_from(InboundSms)
.filter(
.where(
InboundSms.service_id == service_id,
InboundSms.created_at >= midnight_n_days_ago(limit_days),
)
@@ -117,7 +117,7 @@ def _delete_inbound_sms(datetime_to_delete_from, query_filter):
subquery = (
select(InboundSms.id)
.filter(InboundSms.created_at < datetime_to_delete_from, *query_filter)
.where(InboundSms.created_at < datetime_to_delete_from, *query_filter)
.limit(query_limit)
.subquery()
)
@@ -128,7 +128,7 @@ def _delete_inbound_sms(datetime_to_delete_from, query_filter):
while number_deleted > 0:
_insert_inbound_sms_history(subquery, query_limit=query_limit)
stmt = delete(InboundSms).filter(InboundSms.id.in_(subquery))
stmt = delete(InboundSms).where(InboundSms.id.in_(subquery))
number_deleted = db.session.execute(stmt).rowcount
db.session.commit()
deleted += number_deleted
@@ -145,7 +145,7 @@ def delete_inbound_sms_older_than_retention():
stmt = (
select(ServiceDataRetention)
.join(ServiceDataRetention.service)
.filter(ServiceDataRetention.notification_type == NotificationType.SMS)
.where(ServiceDataRetention.notification_type == NotificationType.SMS)
)
flexible_data_retention = db.session.execute(stmt).scalars().all()