mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
add the ability to query jobs based on processed started time rather than created_at
This commit is contained in:
@@ -53,6 +53,7 @@ def dao_get_jobs_by_service_id(
|
|||||||
service_id,
|
service_id,
|
||||||
*,
|
*,
|
||||||
limit_days=None,
|
limit_days=None,
|
||||||
|
use_processing_time=False,
|
||||||
page=1,
|
page=1,
|
||||||
page_size=50,
|
page_size=50,
|
||||||
statuses=None,
|
statuses=None,
|
||||||
@@ -63,7 +64,12 @@ def dao_get_jobs_by_service_id(
|
|||||||
Job.original_file_name != current_app.config["ONE_OFF_MESSAGE_FILENAME"],
|
Job.original_file_name != current_app.config["ONE_OFF_MESSAGE_FILENAME"],
|
||||||
]
|
]
|
||||||
if limit_days is not None:
|
if limit_days is not None:
|
||||||
query_filter.append(Job.created_at >= midnight_n_days_ago(limit_days))
|
if use_processing_time:
|
||||||
|
query_filter.append(
|
||||||
|
func.coalesce(Job.processing_started, Job.created_at) >= midnight_n_days_ago(limit_days)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
query_filter.append(Job.created_at >= midnight_n_days_ago(limit_days))
|
||||||
if statuses is not None and statuses != [""]:
|
if statuses is not None and statuses != [""]:
|
||||||
query_filter.append(Job.job_status.in_(statuses))
|
query_filter.append(Job.job_status.in_(statuses))
|
||||||
|
|
||||||
|
|||||||
@@ -220,6 +220,8 @@ def get_jobs_by_service(service_id):
|
|||||||
else:
|
else:
|
||||||
limit_days = None
|
limit_days = None
|
||||||
|
|
||||||
|
use_processing_time = request.args.get("use_processing_time", "false").lower() == "true"
|
||||||
|
|
||||||
valid_statuses = set(JobStatus)
|
valid_statuses = set(JobStatus)
|
||||||
statuses_arg = request.args.get("statuses", "")
|
statuses_arg = request.args.get("statuses", "")
|
||||||
if statuses_arg == "":
|
if statuses_arg == "":
|
||||||
@@ -236,6 +238,7 @@ def get_jobs_by_service(service_id):
|
|||||||
**get_paginated_jobs(
|
**get_paginated_jobs(
|
||||||
service_id,
|
service_id,
|
||||||
limit_days=limit_days,
|
limit_days=limit_days,
|
||||||
|
use_processing_time=use_processing_time,
|
||||||
statuses=statuses,
|
statuses=statuses,
|
||||||
page=int(request.args.get("page", 1)),
|
page=int(request.args.get("page", 1)),
|
||||||
)
|
)
|
||||||
@@ -325,12 +328,14 @@ def get_paginated_jobs(
|
|||||||
service_id,
|
service_id,
|
||||||
*,
|
*,
|
||||||
limit_days,
|
limit_days,
|
||||||
|
use_processing_time,
|
||||||
statuses,
|
statuses,
|
||||||
page,
|
page,
|
||||||
):
|
):
|
||||||
pagination = dao_get_jobs_by_service_id(
|
pagination = dao_get_jobs_by_service_id(
|
||||||
service_id,
|
service_id,
|
||||||
limit_days=limit_days,
|
limit_days=limit_days,
|
||||||
|
use_processing_time=use_processing_time,
|
||||||
page=page,
|
page=page,
|
||||||
page_size=current_app.config["PAGE_SIZE"],
|
page_size=current_app.config["PAGE_SIZE"],
|
||||||
statuses=statuses,
|
statuses=statuses,
|
||||||
|
|||||||
Reference in New Issue
Block a user