mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 06:52:06 -05:00
give dao_get_inbound_sms_for_service optional day limit
defaults to 6 to preserve backwards compatibility
This commit is contained in:
@@ -14,14 +14,15 @@ def dao_create_inbound_sms(inbound_sms):
|
||||
db.session.add(inbound_sms)
|
||||
|
||||
|
||||
def dao_get_inbound_sms_for_service(service_id, limit=None, user_number=None):
|
||||
start_date = midnight_n_days_ago(6)
|
||||
def dao_get_inbound_sms_for_service(service_id, limit=None, user_number=None, days_ago_to_start=6):
|
||||
q = InboundSms.query.filter(
|
||||
InboundSms.service_id == service_id,
|
||||
InboundSms.created_at >= start_date
|
||||
InboundSms.service_id == service_id
|
||||
).order_by(
|
||||
InboundSms.created_at.desc()
|
||||
)
|
||||
if days_ago_to_start is not None:
|
||||
start_date = midnight_n_days_ago(days_ago_to_start)
|
||||
q = q.filter(InboundSms.created_at >= start_date)
|
||||
|
||||
if user_number:
|
||||
q = q.filter(InboundSms.user_number == user_number)
|
||||
|
||||
Reference in New Issue
Block a user