-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add endpoint and function to set the current operating cycle #65
base: main
Are you sure you want to change the base?
Conversation
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.
I think adding a transaction / context manager would be a small change to add resilience to operations like set_current_operating_cycle()
. The rest looks great.
if previous_cycle is not None: | ||
await previous_cycle.set({Cycle.is_current_operating_cycle: False}) | ||
|
||
await new_current_cycle.set({Cycle.is_current_operating_cycle: True}) | ||
|
||
# Let's now check all is well with the world | ||
expected_current_cycle = await current_operating_cycle(facility) | ||
if str(expected_current_cycle) != cycle: | ||
logger.error(f"Failed to set the current operating cycle for {facility} to be {cycle}.") | ||
return None |
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.
This should probably packaged into a transaction (or at least use some context manager) to rollback on failure and avoid an inconsistent state.
The test at the end could be removed at that point.
Co-authored-by: Padraic Shafer <[email protected]>
Co-authored-by: Padraic Shafer <[email protected]>
Co-authored-by: Padraic Shafer <[email protected]>
I have restricted access to the endpoint to admin API keys