-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
Initial support for Slam (Sludge) pickup/week handling #2355
base: master
Are you sure you want to change the base?
Initial support for Slam (Sludge) pickup/week handling #2355
Conversation
@@ -192,19 +192,38 @@ def fetch(self): | |||
response = requests.get(getUrl, params=params, timeout=30) | |||
|
|||
data = json.loads(response.text) | |||
|
|||
#print(json.dumps(data, indent=2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#print(json.dumps(data, indent=2)) | |
#print(json.dumps(data, indent=2)) |
Looks like a debug left over.
|
||
# When no date is provided, check the frequency for week number | ||
if(next_pickup == ""): | ||
#print(item["WastePickupFrequency"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug left over
# Check if it contains the swedish word for week | ||
if date_parts[0].lower() == "vecka": | ||
# Assemble date from week number | ||
#print("Week number: " + date_parts[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again. Debug left over.
#print("Week number: " + date_parts[1]) | ||
current_year = datetime.now().year | ||
next_pickup_date = datetime.strptime(f"{current_year} {date_parts[1]} 1", "%Y %W %w").date() | ||
#print("Next pickup date: " + str(next_pickup_date)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again. Debug left over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i left the debug messages but commented them out since I thought they could be of use if this (somewhat hacky version to get the date from week numbers) doesn't work for some provider/municipality. But if it's preferred to not include them then sure
You could put the debug messages in the debug logs: I think cleaning the fetch function a bit might be a good idea here. Moving out some conventions in additional functions. |
I got a question if it was possible to also get the sludge pickup date. I looked into it with the Borås Test 3 address. It does not return a NextWastePickup date but it does return a week number in WastePickupFrequency eg "Vecka 27".
There was already an implementation when i merged SSAM into edpevent_se where the NextWastePickup can be returned as "v32 Aug 2024". The previous implementation checked if it contained the letter "v" and then created a date from the string using a month map etc. I built on top of this to also work with a simple "Vecka 27" return value.
Not sure if this is the optimal solution for this? I guess this is a bit hard to solve for everything since different municipalities might write their NextWastePickup in a different way.