mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-27 11:19:21 -04:00
Remove jobs from the dashboard
We’ve done this already for services with the upload letters permission. And all services can upload letters now. But we’re still returning it in the JSON response we use to AJAX-ify the page. Since the jobs response can query stats for up to 50 jobs at a time this puts some load on the API/database. Hopefully this might drop that load a bit.
This commit is contained in:
@@ -309,10 +309,6 @@ def get_dashboard_partials(service_id):
|
||||
[row['count'] for row in template_statistics] or [0]
|
||||
),
|
||||
),
|
||||
'jobs': render_template(
|
||||
'views/dashboard/_jobs.html',
|
||||
jobs=current_service.immediate_jobs,
|
||||
),
|
||||
'usage': render_template(
|
||||
'views/dashboard/_usage.html',
|
||||
**calculate_usage(yearly_usage, free_sms_allowance),
|
||||
|
||||
@@ -8,14 +8,10 @@
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('dashboard') }}" href="{{ url_for('.service_dashboard', service_id=current_service.id) }}">Dashboard</a></li>
|
||||
{% endif %}
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('templates') }}" href="{{ url_for('.choose_template', service_id=current_service.id) }}">Templates</a></li>
|
||||
{% if current_user.has_permissions('view_activity') %}
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('uploads') }}" href="{{ url_for('main.uploads', service_id=current_service.id) }}">Uploads</a></li>
|
||||
{% else %}
|
||||
{% if not current_user.has_permissions('view_activity') %}
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ casework_navigation.is_selected('sent-messages') }}" href="{{ url_for('.view_notifications', service_id=current_service.id, status='sending,delivered,failed') }}">Sent messages</a></li>
|
||||
{% if current_service.has_jobs or current_service.can_upload_letters %}
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ casework_navigation.is_selected('uploads') }}" href="{{ url_for('main.uploads', service_id=current_service.id) }}">Uploads</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('uploads') }}" href="{{ url_for('main.uploads', service_id=current_service.id) }}">Uploads</a></li>
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('team-members') }}" href="{{ url_for('.manage_users', service_id=current_service.id) }}">Team members</a></li>
|
||||
{% if current_user.has_permissions('manage_service', allow_org_user=True) %}
|
||||
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('usage') }}" href="{{ url_for('.usage', service_id=current_service.id) }}">Usage</a></li>
|
||||
|
||||
@@ -35,14 +35,6 @@
|
||||
|
||||
{{ ajax_block(partials, updates_url, 'template-statistics') }}
|
||||
|
||||
{% if current_service.immediate_jobs and not current_service.has_permission('upload_letters') %}
|
||||
{{ ajax_block(partials, updates_url, 'jobs') }}
|
||||
{{ show_more(
|
||||
url_for('.view_jobs', service_id=current_service.id),
|
||||
'See all uploaded files'
|
||||
) }}
|
||||
{% endif %}
|
||||
|
||||
{% if current_user.has_permissions('manage_service') %}
|
||||
<h2 class='heading-medium'>This year</h2>
|
||||
{{ ajax_block(partials, updates_url, 'usage') }}
|
||||
|
||||
@@ -384,6 +384,7 @@ def test_service_navigation_for_org_user(
|
||||
(
|
||||
'Templates',
|
||||
'Sent messages',
|
||||
'Uploads',
|
||||
'Team members',
|
||||
),
|
||||
403,
|
||||
@@ -393,6 +394,7 @@ def test_service_navigation_for_org_user(
|
||||
(
|
||||
'Templates',
|
||||
'Sent messages',
|
||||
'Uploads',
|
||||
'Team members',
|
||||
'Usage',
|
||||
),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import copy
|
||||
import json
|
||||
from datetime import datetime
|
||||
from unittest.mock import call
|
||||
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -903,56 +902,6 @@ def test_correct_font_size_for_big_numbers(
|
||||
) == 3
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_should_show_recent_jobs_on_dashboard(
|
||||
client_request,
|
||||
mock_get_service_templates,
|
||||
mock_get_template_statistics,
|
||||
mock_get_service_statistics,
|
||||
mock_get_jobs,
|
||||
mock_get_usage,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
mock_get_inbound_sms_summary,
|
||||
mock_get_returned_letter_summary_with_no_returned_letters,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.service_dashboard',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
)
|
||||
|
||||
third_call = mock_get_jobs.call_args_list[2]
|
||||
assert third_call[0] == (SERVICE_ONE_ID,)
|
||||
assert third_call[1]['limit_days'] == 7
|
||||
assert 'scheduled' not in third_call[1]['statuses']
|
||||
|
||||
table_rows = page.select_one('tbody').select('tr')
|
||||
|
||||
assert len(table_rows) == 4
|
||||
|
||||
for index, filename in enumerate((
|
||||
"export 1/1/2016.xls",
|
||||
"all email addresses.xlsx",
|
||||
"applicants.ods",
|
||||
"thisisatest.csv",
|
||||
)):
|
||||
assert filename in table_rows[index].find_all('th')[0].text
|
||||
assert 'Sent today at 11:09' in table_rows[index].find_all('th')[0].text
|
||||
assert normalize_spaces(
|
||||
table_rows[index].select_one('td').text
|
||||
) == (
|
||||
'1 sending 0 delivered 0 failed'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('extra_permissions', (
|
||||
pytest.param(
|
||||
[],
|
||||
marks=pytest.mark.xfail(raises=AssertionError),
|
||||
),
|
||||
pytest.param(
|
||||
['upload_letters']
|
||||
),
|
||||
))
|
||||
def test_should_not_show_jobs_on_dashboard_for_users_with_uploads_page(
|
||||
client_request,
|
||||
service_one,
|
||||
@@ -964,9 +913,7 @@ def test_should_not_show_jobs_on_dashboard_for_users_with_uploads_page(
|
||||
mock_get_free_sms_fragment_limit,
|
||||
mock_get_inbound_sms_summary,
|
||||
mock_get_returned_letter_summary_with_no_returned_letters,
|
||||
extra_permissions,
|
||||
):
|
||||
service_one['permissions'] += extra_permissions
|
||||
page = client_request.get(
|
||||
'main.service_dashboard',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
@@ -1546,38 +1493,6 @@ def test_get_tuples_of_financial_years_defaults_to_2015():
|
||||
))[0]
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_should_show_all_jobs_with_valid_statuses(
|
||||
logged_in_client,
|
||||
mock_get_template_statistics,
|
||||
mock_get_service_statistics,
|
||||
mock_get_service_templates_when_no_templates_exist,
|
||||
mock_get_jobs,
|
||||
mock_get_usage,
|
||||
mock_get_inbound_sms_summary,
|
||||
mock_get_returned_letter_summary_with_no_returned_letters,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
):
|
||||
logged_in_client.get(url_for('main.service_dashboard', service_id=SERVICE_ONE_ID))
|
||||
|
||||
first_call = mock_get_jobs.call_args_list[0]
|
||||
# first call - checking for any jobs
|
||||
assert first_call == call(SERVICE_ONE_ID)
|
||||
second_call = mock_get_jobs.call_args_list[1]
|
||||
# second call - scheduled jobs only
|
||||
assert second_call == call(SERVICE_ONE_ID, statuses=['scheduled'])
|
||||
# third call - everything but scheduled and cancelled
|
||||
third_call = mock_get_jobs.call_args_list[2]
|
||||
assert third_call == call(SERVICE_ONE_ID, limit_days=7, statuses={
|
||||
'pending',
|
||||
'in progress',
|
||||
'finished',
|
||||
'sending limits exceeded',
|
||||
'ready to send',
|
||||
'sent to dvla'
|
||||
})
|
||||
|
||||
|
||||
def test_org_breadcrumbs_do_not_show_if_service_has_no_org(
|
||||
client_request,
|
||||
mock_get_template_statistics,
|
||||
|
||||
@@ -191,7 +191,7 @@ def test_caseworkers_get_caseworking_navigation(
|
||||
)
|
||||
page = client_request.get('main.choose_template', service_id=SERVICE_ONE_ID)
|
||||
assert normalize_spaces(page.select_one('header + .govuk-width-container nav').text) == (
|
||||
'Templates Sent messages Team members'
|
||||
'Templates Sent messages Uploads Team members'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user