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

AWB Emsland request this AND next years data instead of only next years #3134

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

niklasdoerfler
Copy link
Contributor

This PR tries to fix #3131 by adding a new (optional) parameter, in which the corresponding request period can be entered to override the default request period.

Therefore, for the specific issue, you can enter "Jahresübersicht 2024" to get the waste collection schedule for the current year.

@5ila5
Copy link
Collaborator

5ila5 commented Dec 3, 2024

If it's always Jahresübersicht {YEAR} I think it is better to set this in the code instead of the user. In your approach, the user needs to change the config regularly. I think the best way to approach this is to rename the fetch method to get_collections(self, year: int) -> List[Collections) and set the year according to the parameter and use a new fetch method like this:

def fetch(self) -> List[Collections]:
  now = datetime.now()
  entries = self.get_collections(now.year)
  if now.month != 12:
    return entries
  try:
    return entries + self.get_collections(now.year + 1)
  except Exception:
    return entries

@niklasdoerfler
Copy link
Contributor Author

I agree, that's a good point! That's why I've now tried a different approach, where I first query all available years and then retrieve the corresponding iCals and merge them all.

@5ila5 5ila5 changed the title Add optional arg to override request period for AWB Emsland AWB Emsland request this AND next years data instead of only next years Dec 12, 2024
@5ila5 5ila5 merged commit 740922e into mampfes:master Dec 12, 2024
2 checks passed
@5ila5
Copy link
Collaborator

5ila5 commented Dec 12, 2024

Thanks for your contribution. I like this approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: AWB Emsland changed to 2025. Actual 2024 will be ignored
2 participants