-
Notifications
You must be signed in to change notification settings - Fork 2
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 plausibility check for realtime_free_capacity values #222
base: main
Are you sure you want to change the base?
Add plausibility check for realtime_free_capacity values #222
Conversation
webapp/services/import_service/generic/generic_import_service.py
Outdated
Show resolved
Hide resolved
@@ -273,6 +273,34 @@ def _save_realtime_parking_site_input(self, source: Source, realtime_parking_sit | |||
original_uid=realtime_parking_site_input.uid, | |||
) | |||
|
|||
parking_site_capacities = [ |
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.
Typing :)
Also: the essential information is just one value: ' capacity' or 'capacity_woman' or ... . So it could be just a list of string, and then:
fields: list[str] = ['capacity', 'capacity_woman']
for field in fields:
realtime_free_capacity = getattr(realtime_parking_site_input, f'realtime_free_{field}')
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.
now resolved, thanks for the hint!
setattr(realtime_parking_site_input, realtime_free_capacity, parking_site_capacity) | ||
self.logger.warn( | ||
LogMessageType.FAILED_PARKING_SITE_HANDLING, | ||
f'At {parking_site.original_uid} from {source.id}, {realtime_free_capacity_type} {realtime_free_capacity} was higher than {realtime_capacity_type} {parking_site_capacity}', |
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 line is to long. Please make sure that you use ruff
before committing. This can be done automatically using the pre commit hook which is part of the project. For more information about pre commit hooks, please visit https://pre-commit.com (not sure if that works at Windows, though).
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 PR checks if realtime free capacity
realtime_free_capacity
values are higher than the actual capacity before saving. It sets the realtime capacity values to the value of the actual capacity if it is true. The same plausibilty check is applied to each capacity category e.g.realtime_free_capacity_woman
,realtime_free_capacity_disabled
etc.