mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 14:08:25 -04:00
Use a ModelList for lists of jobs
This follows the pattern of what we’ve done with services, users and events. It gives us a way of neatly instantiating a model for each item in the list we get back from the API and reduces the complexity of the view layer code. Now is a good time to do this because we’re going to be making a bunch of changes to the jobs pages, and those changes will be easier to code and understand with a sensible model behind them.
This commit is contained in:
@@ -20,12 +20,11 @@ from app import (
|
||||
current_service,
|
||||
format_date_numeric,
|
||||
format_datetime_numeric,
|
||||
job_api_client,
|
||||
service_api_client,
|
||||
template_statistics_client,
|
||||
)
|
||||
from app.main import main
|
||||
from app.statistics_utils import add_rate_to_job, get_formatted_percentage
|
||||
from app.statistics_utils import get_formatted_percentage
|
||||
from app.utils import (
|
||||
DELIVERED_STATUSES,
|
||||
FAILURE_STATUSES,
|
||||
@@ -281,14 +280,6 @@ def get_dashboard_partials(service_id):
|
||||
all_statistics = template_statistics_client.get_template_statistics_for_service(service_id, limit_days=7)
|
||||
template_statistics = aggregate_template_usage(all_statistics)
|
||||
|
||||
scheduled_jobs, immediate_jobs = [], []
|
||||
if job_api_client.has_jobs(service_id):
|
||||
scheduled_jobs = job_api_client.get_scheduled_jobs(service_id)
|
||||
immediate_jobs = [
|
||||
add_rate_to_job(job)
|
||||
for job in job_api_client.get_immediate_jobs(service_id)
|
||||
]
|
||||
|
||||
stats = aggregate_notifications_stats(all_statistics)
|
||||
column_width, max_notifiction_count = get_column_properties(3)
|
||||
|
||||
@@ -310,7 +301,6 @@ def get_dashboard_partials(service_id):
|
||||
return {
|
||||
'upcoming': render_template(
|
||||
'views/dashboard/_upcoming.html',
|
||||
scheduled_jobs=scheduled_jobs
|
||||
),
|
||||
'inbox': render_template(
|
||||
'views/dashboard/_inbox.html',
|
||||
@@ -337,9 +327,8 @@ def get_dashboard_partials(service_id):
|
||||
),
|
||||
'jobs': render_template(
|
||||
'views/dashboard/_jobs.html',
|
||||
jobs=immediate_jobs
|
||||
jobs=current_service.immediate_jobs,
|
||||
),
|
||||
'has_jobs': bool(immediate_jobs),
|
||||
'usage': render_template(
|
||||
'views/dashboard/_usage.html',
|
||||
column_width=column_width,
|
||||
|
||||
Reference in New Issue
Block a user