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

Cache pretix data locally #165

Merged
merged 6 commits into from
Jul 14, 2024

Conversation

NMertsch
Copy link
Contributor

@NMertsch NMertsch commented Jul 7, 2024

Currently, pretix data is fetched regularly and kept in memory. When the bot is restarted, all pretix data has to be fetched again, so if we restart the bot while pretix is offline, no registrations are possible.

The PR adds caching of Pretix data in a local file, which is used when the bot is starting up.

Implementation: On each successful pretix data fetch, all in-memory pretix data is written to the persistent file pretix_cache.json. On bot startup, the content of this file is used as initial state before the first successful pretix fetch occurred.

Details:

  • Change type of class Ticket from dataclasses.dataclass to pydantic.BaseModel to simplify JSON de-/serialization.
  • Add config value pretix.PRETIX_CACHE_FILE
  • Add file pretix_cache.json to .gitignore, ansible playbook, docker-compose

@NMertsch NMertsch force-pushed the 149-cache-pretix-data-locally branch from 9d1b5bb to b69a686 Compare July 13, 2024 08:39
@@ -43,6 +44,7 @@ LOG_LEVEL = "INFO"
timezone_offset = 2
api_url = "https://programapi24.europython.eu/2024/schedule.json"
schedule_cache_file = "schedule.json"
livestream_url_file = "livestreams.toml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@egeakman egeakman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you!

@NMertsch NMertsch merged commit d7e1622 into EuroPython:main Jul 14, 2024
2 checks passed
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.

2 participants