Add property to contact lists to say if they’ve ever been used

At the moment we return a count of recent jobs for contact lists, where
recent is defined as being within the service’s data retention period.

This lets us write nice bits of UI copy like ‘used 3 times in the last
7 days’. But it’s hard to write the copy for when the count is 0,
because this could be for one of two reasons:
- the contact list has never been used
- the contact list has been used, but not within the data retention
  period for that channel

At the moment we can’t know which of those reasons is the case, so we
can’t write nice clear content like ‘never been used’.

This commit adds a property to contact lists which says whether they’ve
ever been used.

It also renames the existing, as-yet-unused property to make clear that
it’s only counting within the data retention (so can still be 0 even if
`has_jobs` is `True`).
This commit is contained in:
Chris Hill-Scott
2020-05-28 13:22:47 +01:00
parent 5b401eaf8d
commit dbbff3ba64
2 changed files with 12 additions and 4 deletions

View File

@@ -69,7 +69,7 @@ def test_get_contact_list(admin_request, notify_db_session):
assert len(response) == 1
assert response[0] == contact_list.serialize()
assert response[0]['job_count'] == 0
assert response[0]['recent_job_count'] == 0
@pytest.mark.parametrize('days_of_email_retention, expected_job_count', (
@@ -107,10 +107,12 @@ def test_get_contact_list_counts_jobs(
assert len(response) == 2
assert response[0]['id'] == str(contact_list_2.id)
assert response[0]['job_count'] == expected_job_count
assert response[0]['recent_job_count'] == expected_job_count
assert response[0]['has_jobs'] is True
assert response[1]['id'] == str(contact_list_1.id)
assert response[1]['job_count'] == 0
assert response[1]['recent_job_count'] == 0
assert response[1]['has_jobs'] is False
def test_get_contact_list_returns_for_service(admin_request, notify_db_session):