mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-13 06:54:20 -05:00
broadcast-areas: do not use group table
do not need it Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -109,16 +109,6 @@ dataset_name = "Electoral Wards of the United Kingdom"
|
||||
dataset_id = make_string_safe_for_id(dataset_name)
|
||||
repo.insert_broadcast_area_library(dataset_id, dataset_name, True)
|
||||
|
||||
for f in geojson.loads(las_filepath.read_text())["features"]:
|
||||
group_id = dataset_id + "-" + f["properties"]["LAD19CD"]
|
||||
group_name = f["properties"]["LAD19NM"]
|
||||
|
||||
try:
|
||||
repo.insert_broadcast_area_library_group(group_id, group_name, dataset_id)
|
||||
except sqlite3.IntegrityError:
|
||||
# Already exists
|
||||
pass
|
||||
|
||||
areas_to_add = []
|
||||
|
||||
for f in geojson.loads(wards_filepath.read_text())["features"]:
|
||||
|
||||
@@ -68,17 +68,6 @@ class BroadcastAreasRepository(object):
|
||||
with self.conn() as conn:
|
||||
conn.execute(q, (id, name, is_group))
|
||||
|
||||
def insert_broadcast_area_library_group(self, id, name, library_id):
|
||||
|
||||
q = """
|
||||
INSERT INTO broadcast_area_library_groups
|
||||
(id, name, broadcast_area_library_id)
|
||||
VALUES (?, ?, ?)
|
||||
"""
|
||||
|
||||
with self.conn() as conn:
|
||||
conn.execute(q, (id, name, library_id))
|
||||
|
||||
def insert_broadcast_areas(self, areas):
|
||||
|
||||
q = """
|
||||
@@ -196,8 +185,9 @@ class BroadcastAreasRepository(object):
|
||||
def get_all_groups_for_library(self, library_id):
|
||||
q = """
|
||||
SELECT id, name
|
||||
FROM broadcast_area_library_groups
|
||||
WHERE broadcast_area_library_id = ?
|
||||
FROM broadcast_areas
|
||||
WHERE broadcast_area_library_group_id = NULL
|
||||
AND broadcast_area_library_id = ?
|
||||
"""
|
||||
|
||||
results = self.query(q, library_id)
|
||||
|
||||
@@ -155,6 +155,20 @@ def test_includes_electoral_wards():
|
||||
assert len(areas) == 1
|
||||
|
||||
|
||||
def test_electoral_wards_are_groupable_cardiff():
|
||||
areas = broadcast_area_libraries.get_areas(['electoral-wards-of-the-united-kingdom-W06000015'])
|
||||
assert len(areas) == 1
|
||||
cardiff = areas[0]
|
||||
assert len(cardiff.sub_areas) == 29
|
||||
|
||||
|
||||
def test_electoral_wards_are_groupable_ealing():
|
||||
areas = broadcast_area_libraries.get_areas(['electoral-wards-of-the-united-kingdom-E09000009'])
|
||||
assert len(areas) == 1
|
||||
ealing = areas[0]
|
||||
assert len(ealing.sub_areas) == 23
|
||||
|
||||
|
||||
def test_repository_has_all_libraries():
|
||||
repo = BroadcastAreasRepository()
|
||||
libraries = repo.get_libraries()
|
||||
|
||||
Reference in New Issue
Block a user