-
Notifications
You must be signed in to change notification settings - Fork 5
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
Migrate db to sqlalchemy #83
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Changes: - Removing pyparsing (3.0.7) - Updating packaging (21.3 -> 24.1) - Updating gunicorn (21.2.0 -> 23.0.0) - Updating psycopg2-binary (2.9.9 -> 2.9.10) - Updating pysqlite3 (0.5.3 -> 0.5.4) - Updating pytz (2024.1 -> 2024.2) Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
whois/web.py
Outdated
devices = device_repository.get_all() | ||
recent = filter_recent(timedelta(**settings.recent_time), devices) |
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 would prefer to keep get_recent
in device_repository
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.
Moved to the DeviceRepository: ce1ef8e
whois/web.py
Outdated
visible_devices = filter_hidden(recent) | ||
users = filter_hidden(owners_from_devices(visible_devices)) | ||
|
||
if current_user.is_authenticated: | ||
unclaimed = unclaimed_devices(recent) | ||
mine = current_user.devices | ||
mine = filter(lambda device: device.owner == current_user.get_id(), devices) |
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.
it this not possible to keep this logic within current_user
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 am not sure if it's fully possible like the old way, but as a compromise I implemented this fetch in the DeviceRepository, where we pass the current_user.get_id()
whois/settings_test.py
Outdated
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.
why is this file needed?
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 file indeed was not used at the moment and removed. I t was planned to have multiple configurations for the app. This functionality was implemented here -> 32d9f54
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
This reverts commit 44a4736.
…ings Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
Signed-off-by: Eduard Kaverinskyi <[email protected]>
@not7cd I implemented everything I wanted in this PR, and I think it is ready for review. To not grow this PR any further I would focus on testing and merging this, and to implement/move any other functionality in separate PR's/issues |
@not7cd Additionally, since you are much more experienced with Mikrotik, I would like to ask you to review the structure of the settings templates: |
@oneacik As we agreed, added you as a reviewer |
The goal of this PR is to migrate from <Flask + peewee> to <Flask + SQLAlchemy> stack. The migration is also followed by a partial refactoring on the MVP patter (sort of), but without a presenter right now.
While I tested the setup manually, I would like to write more tests to simplify validation. Right now the PR is in the Draft phase.
Another thing is that I implemented a BitField type, and after testing I realized that it may be a misuse/overkill. It supports multiple flags, where each bit is a flag. In the current version of the application we need it to store the anonymity, which might be better implemented via Enum or something. I am not sure if we would need this BitField in the future. Please let me know in the comments.
P.S: I will also check for missing type hints and docstrings (I have to write many) later.