move job statuses to job_api_client

prevent code duplication and a good excuse to use set subtraction
This commit is contained in:
Leo Hemsted
2016-10-11 10:35:33 +01:00
parent 0fdd38b9c5
commit 8464c67a3d
3 changed files with 12 additions and 12 deletions

View File

@@ -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)

View File

@@ -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']

View File

@@ -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")