Show upcoming jobs on the dashboard

On the dashboard:
- adds a new ‘in the next 24 hours’ section to the dashboard which lists
  upcoming jobs
- tweaks some spacing on the dashboard so that it doesn’t look like too
  much of a mess
- don’t show scheduled jobs in the table of normal jobs

On the jobs page:
- don’t show scheduled jobs
This commit is contained in:
Chris Hill-Scott
2016-08-09 10:39:57 +01:00
parent 3d8d160d3e
commit 4342b721f1
14 changed files with 165 additions and 40 deletions

View File

@@ -116,9 +116,21 @@ def get_dashboard_partials(service_id):
lambda job: job['original_file_name'] != current_app.config['TEST_MESSAGE_FILENAME'],
job_api_client.get_job(service_id, limit_days=7)['data']
))
scheduled_jobs = filter(
lambda job: job['job_status'] == 'scheduled',
jobs
)
immediate_jobs = filter(
lambda job: job['job_status'] != 'scheduled',
jobs
)
service = service_api_client.get_detailed_service(service_id)
return {
'upcoming': render_template(
'views/dashboard/_upcoming.html',
scheduled_jobs=scheduled_jobs
),
'totals': render_template(
'views/dashboard/_totals.html',
service_id=service_id,
@@ -134,7 +146,7 @@ def get_dashboard_partials(service_id):
'has_template_statistics': bool(template_statistics),
'jobs': render_template(
'views/dashboard/_jobs.html',
jobs=jobs
jobs=immediate_jobs
),
'has_jobs': bool(jobs),
'usage': render_template(

View File

@@ -65,7 +65,10 @@ def _set_status_filters(filter_args):
def view_jobs(service_id):
return render_template(
'views/jobs/jobs.html',
jobs=add_rate_to_jobs(job_api_client.get_job(service_id)['data'])
jobs=filter(
lambda job: job['job_status'] != 'scheduled',
add_rate_to_jobs(job_api_client.get_job(service_id)['data'])
)
)
@@ -274,6 +277,11 @@ def get_status_filters(service, message_type, statistics):
def _get_job_counts(job, help_argument):
sending = 0 if job['job_status'] == 'pending' else (
job.get('notification_count', 0) -
job.get('notifications_delivered', 0) -
job.get('notifications_failed', 0)
)
return [
(
label,
@@ -293,9 +301,7 @@ def _get_job_counts(job, help_argument):
],
[
'sending', 'sending',
job.get('notification_count', 0) -
job.get('notifications_delivered', 0) -
job.get('notifications_failed', 0)
sending
],
[
'delivered', 'delivered',