Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more output to Aylesbury Vale Council #317

Merged
merged 3 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"Type": {
"type": "string",
"enum": [
"Recycling",
"Garden",
"Refuse",
"Food",
"Refuse"
"Garden",
"Recycling"
],
"title": "Type"
}
Expand Down
2 changes: 1 addition & 1 deletion uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uprn": "766252532",
"url": "http://avdcbins.web-labs.co.uk/RefuseApi.asmx",
"wiki_name": "Aylesbury Vale Council (Buckinghamshire)",
"wiki_note": "To get the UPRN, you will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
"wiki_note": "To get the UPRN, you will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN. Returns all published collections in the past, present, future"
},
"BasingstokeCouncil": {
"SKIP_GET_URL": "SKIP_GET_URL",
Expand Down
32 changes: 20 additions & 12 deletions uk_bin_collection/tests/outputs/AylesburyValeCouncil.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
{
"bins": [
{
"type": "Recycling",
"collectionDate": "14/08/2023"
"type": "Refuse",
"collectionDate": "07/08/2023"
},
{
"type": "Food",
"collectionDate": "07/08/2023"
},
{
"type": "Garden",
"collectionDate": "14/08/2023"
},
{
"type": "Recycling",
"collectionDate": "14/08/2023"
},
{
"type": "Food",
"collectionDate": "14/08/2023"
Expand All @@ -21,11 +29,11 @@
"collectionDate": "21/08/2023"
},
{
"type": "Recycling",
"type": "Garden",
"collectionDate": "29/08/2023"
},
{
"type": "Garden",
"type": "Recycling",
"collectionDate": "29/08/2023"
},
{
Expand All @@ -41,11 +49,11 @@
"collectionDate": "04/09/2023"
},
{
"type": "Recycling",
"type": "Garden",
"collectionDate": "11/09/2023"
},
{
"type": "Garden",
"type": "Recycling",
"collectionDate": "11/09/2023"
},
{
Expand All @@ -61,11 +69,11 @@
"collectionDate": "18/09/2023"
},
{
"type": "Recycling",
"type": "Garden",
"collectionDate": "25/09/2023"
},
{
"type": "Garden",
"type": "Recycling",
"collectionDate": "25/09/2023"
},
{
Expand All @@ -81,11 +89,11 @@
"collectionDate": "02/10/2023"
},
{
"type": "Recycling",
"type": "Garden",
"collectionDate": "09/10/2023"
},
{
"type": "Garden",
"type": "Recycling",
"collectionDate": "09/10/2023"
},
{
Expand All @@ -101,11 +109,11 @@
"collectionDate": "16/10/2023"
},
{
"type": "Recycling",
"type": "Garden",
"collectionDate": "23/10/2023"
},
{
"type": "Garden",
"type": "Recycling",
"collectionDate": "23/10/2023"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,44 +48,16 @@ def parse_data(self, page: str, **kwargs) -> dict:
for i in range(len(all_collections)):

collection_date = datetime.strptime(all_collections[i].Date.get_text(), "%Y-%m-%dT%H:%M:%S")
# Often the first BinCollection is the previous one
# The DateTime is set at 7AM so only compare the date element to make sure it captures today's collection at any time of day.
if collection_date.date() < datetime.today().date():
continue
children = all_collections[i].find_all(["Refuse", "Recycling", "Garden", "Food"], string='true')

if all_collections[i].Refuse.get_text() == "true":
bin_type = "Refuse"
for collection in children:
dict_data = {
"type": bin_type,
"collectionDate": collection_date.strftime(date_format)
}
data["bins"].append(dict_data)

if all_collections[i].Recycling.get_text() == "true":
bin_type = "Recycling"
dict_data = {
"type": bin_type,
"collectionDate": collection_date.strftime(date_format)
}
data["bins"].append(dict_data)

if all_collections[i].Garden.get_text() == "true":
bin_type = "Garden"
dict_data = {
"type": bin_type,
"collectionDate": collection_date.strftime(date_format)
}
data["bins"].append(dict_data)

if all_collections[i].Food.get_text() == "true":
bin_type = "Food"
dict_data = {
"type": bin_type,
"type": collection.name,
"collectionDate": collection_date.strftime(date_format)
}
data["bins"].append(dict_data)

data["bins"].sort(
key=lambda x: datetime.strptime(x.get("collectionDate"), date_format)
)
return data
return data