-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 central db #48
11 central db #48
Conversation
Need to work out abstraction whilst still keeping it plugin based Looking at mongogettersetter library
Playing around with structure for MongoDB interface for the plugins
Datetime handling has been updated to use UTC timezone in 'last_updated' attribute of 'SpaceState' class and in __setattr__ method. This ensures all generated timestamps are in UTC.
Refactor mongo context in tests to ignore the return value of collection update. Also, the state of 'SpaceState' object has been printed at the beginning to help understand its initial state better.
Implemented MongoDB for persisting plugin data through the Mogo wrapper. Refactored Slack and Common code configurations, including the relocation of functions and addition of MongoDB environment variables. This also led to new database related files creation, as well as Docker Compose and Python project environment alterations.
Major changes: 1. Apply `@database` decorator to `space_open`, `space_closed` and `get_space_state` methods in 'smib/slack/plugins/space/openclose/__init__.py' to streamline connection to DB. 2. Implemented `database()` decorator use in 'smib/slack/db/__init__.py', configured to automatically get the current plugin id for the DB if input argument is not provided. 3. Removed unused methods `connect_to_plugin_database` and `get_plugin_database` from 'smib/slack/db/__init__.py'. 4. Moved `get_current_plugin_id()` method to 'smib/slack/db/__init__.py' to manage plugin id for DB operations. 5. Updated import statements and DB connection details in various other files. Minor modifications: 1. Adjusted import statements and logging configuration across files for consistency. 2. Handled the connection timeout setting for the MongoDB connection within the `database()` decorator. These changes aim to enhance the clarity and robustness of database operations within the codebase.
# Conflicts: # docker-compose.yml # smib/.env # smib/slack/__main__.py
Added a new function `is_json_encodable` to utils.py for checking if a value can be serialized to JSON, and updated the `get_space_state` method in the openclose plugin. The updated method now returns a dictionary of objects from the Space class that are JSON-encodable, shifting the focus on ensuring data compatibility with JSON serialization.
…ners on the same network. Removed timezone stuff from smib-fast.Dockerfile. This needs to be looked at again as wasnt running on my Pi.
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.
@sam57719 In general I think we need to ensure future PRs are smaller in scope. Ideally splitting into discrete features such as DB engine and driver, plugin updates etc.
I'll give it a once over and see what I can get from reading through and also give it a test on my local server. Would be good to get a review of the components added and design decisions on Wednesday so I'm up to speed ahead of merging in.
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.
@sam57719 Would be good to have some documentation updates to go with this PR. Probably just some lines in root dir readme detailing the features added, how to consume as a user and/or developer. You can make some headings up as you need like "plugins" or "API" or "tests" and I can merge my docs into them should I get to documenting the core code at some point.
@sjefferson99 did some command line stuff on my pi 4 in France. got it running - there seem to be a bunch of active connections still Had to pin the version number of the mongo container to the lastest one that wosk on a pi Ensured all containers on same docker network and told smib-slack what the hostname of the mongo-db container is |
The mongogettersetter dependency is removed from the pyproject.toml file and the poetry.lock file. As the project no longer requires this package, it has been removed to keep the dependencies simpler and cleaner.
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.
Happy with PR. Needs to be smaller in future and random tests can go in random branches.
Database is done - I am happy.
Implemented HTTP get space_state endpoint that returns whether the space is open or not.