-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = [ | ||
('realtime_capacity', 'realtime_free_capacity', parking_site.capacity), | ||
('realtime_capacity_woman', 'realtime_free_capacity_woman', parking_site.capacity_woman), | ||
('realtime_capacity_disabled', 'realtime_free_capacity_disabled', parking_site.capacity_disabled), | ||
('realtime_capacity_charging', 'realtime_free_capacity_charging', parking_site.capacity_charging), | ||
('realtime_capacity_carsharing', 'realtime_free_capacity_carsharing', parking_site.capacity_carsharing), | ||
('realtime_capacity_bus', 'realtime_free_capacity_bus', parking_site.capacity_bus), | ||
('realtime_capacity_family', 'realtime_free_capacity_family', parking_site.capacity_family), | ||
('realtime_capacity_truck', 'realtime_free_capacity_truck', parking_site.capacity_truck), | ||
] | ||
|
||
for realtime_capacity_type, realtime_free_capacity_type, parking_site_capacity in parking_site_capacities: | ||
realtime_free_capacity = getattr(realtime_parking_site_input, realtime_free_capacity_type) | ||
realtime_capacity = getattr(realtime_parking_site_input, realtime_capacity_type) | ||
|
||
if realtime_capacity == UnsetValue and realtime_free_capacity > parking_site.capacity: | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This line is to long. Please make sure that you use |
||
) | ||
elif realtime_capacity != UnsetValue and realtime_free_capacity > realtime_capacity: | ||
setattr(realtime_parking_site_input, realtime_free_capacity, realtime_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} {realtime_capacity}', | ||
) | ||
|
||
history_enabled: bool = self.config_helper.get('HISTORY_ENABLED', False) | ||
history_changed = False | ||
for key, value in realtime_parking_site_input.to_dict().items(): | ||
|
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: