This commit is contained in:
Kenneth Kehl
2024-11-18 14:54:49 -08:00
parent ce5b9cf055
commit 38e7672866
2 changed files with 11 additions and 10 deletions

View File

@@ -84,7 +84,7 @@ def dao_count_inbound_sms_for_service(service_id, limit_days):
def _insert_inbound_sms_history(subquery, query_limit=10000):
offset = 0
subquery_select = select(subquery)
inbound_sms_query = select(
inbound_sms_querie = select(
InboundSms.id,
InboundSms.created_at,
InboundSms.service_id,
@@ -94,13 +94,13 @@ def _insert_inbound_sms_history(subquery, query_limit=10000):
InboundSms.provider,
).where(InboundSms.id.in_(subquery_select))
count_query = select(func.count()).select_from(inbound_sms_query.subquery())
count_query = select(func.count()).select_from(inbound_sms_querie.subquery())
inbound_sms_count = db.session.execute(count_query).scalar() or 0
while offset < inbound_sms_count:
statement = insert(InboundSmsHistory).from_select(
InboundSmsHistory.__table__.c,
inbound_sms_query.limit(query_limit).offset(offset),
inbound_sms_querie.limit(query_limit).offset(offset),
)
statement = statement.on_conflict_do_nothing(