mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-05 01:51:28 -04:00
move job statuses to job_api_client
prevent code duplication and a good excuse to use set subtraction
This commit is contained in:
@@ -116,12 +116,7 @@ def aggregate_usage(template_statistics):
|
||||
|
||||
def get_dashboard_partials(service_id):
|
||||
# all but scheduled and cancelled
|
||||
statuses_to_display = [
|
||||
'pending',
|
||||
'in progress',
|
||||
'finished',
|
||||
'sending limits exceeded',
|
||||
]
|
||||
statuses_to_display = job_api_client.JOB_STATUSES - {'scheduled', 'cancelled'}
|
||||
|
||||
template_statistics = aggregate_usage(
|
||||
template_statistics_client.get_template_statistics_for_service(service_id, limit_days=7)
|
||||
|
||||
@@ -67,12 +67,7 @@ def _set_status_filters(filter_args):
|
||||
def view_jobs(service_id):
|
||||
page = int(request.args.get('page', 1))
|
||||
# all but scheduled and cancelled
|
||||
statuses_to_display = [
|
||||
'pending',
|
||||
'in progress',
|
||||
'finished',
|
||||
'sending limits exceeded',
|
||||
]
|
||||
statuses_to_display = job_api_client.JOB_STATUSES - {'scheduled', 'cancelled'}
|
||||
jobs_response = job_api_client.get_jobs(service_id, statuses=statuses_to_display, page=page)
|
||||
jobs = [
|
||||
add_rate_to_job(job) for job in jobs_response['data']
|
||||
|
||||
@@ -5,6 +5,16 @@ from app.notify_client import _attach_current_user
|
||||
|
||||
|
||||
class JobApiClient(BaseAPIClient):
|
||||
|
||||
JOB_STATUSES = {
|
||||
'scheduled',
|
||||
'pending',
|
||||
'in progress',
|
||||
'finished',
|
||||
'cancelled',
|
||||
'sending limits exceeded',
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a", "b", "c")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user