Exclude grouped areas from examples

The given examples should match the choices offered when you visit the
next page. The choices offered on the next page are either the areas
(when a library is not grouped) or the groups (when a library is
grouped).

This commit makes the examples match the choices by excluding sub-areas,
ie those that have a grouping ID.
This commit is contained in:
Chris Hill-Scott
2020-08-12 12:02:56 +01:00
parent 781847d32c
commit 53fd5b8869
2 changed files with 6 additions and 3 deletions

View File

@@ -114,8 +114,11 @@ class BroadcastAreasRepository(object):
def get_library_description(self, library_id):
q = """
WITH
areas AS (SELECT * FROM broadcast_areas
WHERE broadcast_area_library_id = ?),
areas AS (
SELECT * FROM broadcast_areas
WHERE broadcast_area_library_id = ?
AND broadcast_area_library_group_id IS NULL
),
area_count AS (SELECT COUNT(*) AS c FROM areas),
subset_area_count AS (SELECT c - 4 FROM area_count),
description_area_names AS (SELECT name FROM areas LIMIT 4),

View File

@@ -61,7 +61,7 @@ def test_examples():
wards = broadcast_area_libraries.get(
'electoral-wards-of-the-united-kingdom',
).get_examples()
assert wards == 'Abbey, Alibon, Becontree, Chadwell Heath, and 8970 more…'
assert wards == 'Hartlepool, Middlesbrough, Redcar and Cleveland, Stockton-on-Tees, and 375 more…'
@pytest.mark.parametrize('id', (