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

Add plausibility check for realtime_free_capacity values #222

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AbdullahiFatola
Copy link

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.

@@ -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 = [
Copy link
Collaborator

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}')

Copy link
Author

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}',
Copy link
Collaborator

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).

Copy link
Author

@AbdullahiFatola AbdullahiFatola Jan 8, 2025

Choose a reason for hiding this comment

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

I get this error, when I run pre commit hook:
Any idea on what the error is all about and how to resolve it?
image

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