From 4ade643de6563d18fb912d476ff158afaf84f09f Mon Sep 17 00:00:00 2001
From: Edward Betts <edward@4angle.com>
Date: Tue, 5 Mar 2024 10:07:21 +0100
Subject: [PATCH] Move UPRN and postcode values to config

Closes: #136
---
 agenda/data.py         | 27 ++++++++++++++++++---------
 update_bristol_bins.py |  4 +---
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/agenda/data.py b/agenda/data.py
index c84c7c0..3e3efa0 100644
--- a/agenda/data.py
+++ b/agenda/data.py
@@ -105,11 +105,10 @@ def dates_from_rrule(
     ]
 
 
-async def waste_collection_events(data_dir: str) -> list[Event]:
+async def waste_collection_events(
+    data_dir: str, postcode: str, uprn: str
+) -> list[Event]:
     """Waste colllection events."""
-    postcode = "BS48 3HG"
-    uprn = "24071046"
-
     html = await waste_schedule.get_html(data_dir, postcode, uprn)
     root = lxml.html.fromstring(html)
     events = waste_schedule.parse(root)
@@ -117,11 +116,9 @@ async def waste_collection_events(data_dir: str) -> list[Event]:
 
 
 async def bristol_waste_collection_events(
-    data_dir: str, start_date: date
+    data_dir: str, start_date: date, uprn: str
 ) -> list[Event]:
     """Waste colllection events."""
-    uprn = "358335"
-
     return await waste_schedule.get_bristol_gov_uk(start_date, data_dir, uprn)
 
 
@@ -375,8 +372,20 @@ async def get_data(
     t0 = time()
     result_list = await asyncio.gather(
         time_function("gwr_advance_tickets", gwr.advance_ticket_date, data_dir),
-        time_function("backwell_bins", waste_collection_events, data_dir),
-        time_function("bristol_bins", bristol_waste_collection_events, data_dir, today),
+        time_function(
+            "backwell_bins",
+            waste_collection_events,
+            data_dir,
+            config["BACKWELL_POSTCODE"],
+            config["BACKWELL_UPRN"],
+        ),
+        time_function(
+            "bristol_bins",
+            bristol_waste_collection_events,
+            data_dir,
+            today,
+            config["BRISTOL_UPRN"],
+        ),
     )
     rockets = thespacedevs.read_cached_launches(rocket_dir)
 
diff --git a/update_bristol_bins.py b/update_bristol_bins.py
index 9b489e9..80ab91c 100755
--- a/update_bristol_bins.py
+++ b/update_bristol_bins.py
@@ -14,10 +14,8 @@ config = __import__("config.default", fromlist=[""])
 
 async def bristol_waste_collection_events() -> list[agenda.types.Event]:
     """Waste colllection events."""
-    uprn = "358335"
-
     return await agenda.waste_schedule.get_bristol_gov_uk(
-        date.today(), config.DATA_DIR, uprn, refresh=True
+        date.today(), config.DATA_DIR, config.BRISTOL_UPRN, refresh=True
     )