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

11 central db #48

Merged
merged 14 commits into from
May 8, 2024
Merged

11 central db #48

merged 14 commits into from
May 8, 2024

Conversation

sam57719
Copy link
Collaborator

@sam57719 sam57719 commented May 2, 2024

Database is done - I am happy.

Implemented HTTP get space_state endpoint that returns whether the space is open or not.

sam57719 added 10 commits April 25, 2024 00:31
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
@sam57719 sam57719 added this to the Prod MVP milestone May 2, 2024
@sam57719 sam57719 requested a review from sjefferson99 May 2, 2024 00:06
@sam57719 sam57719 linked an issue May 2, 2024 that may be closed by this pull request
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.
Copy link
Member

@sjefferson99 sjefferson99 left a 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.

Copy link
Member

@sjefferson99 sjefferson99 left a 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.

@sam57719
Copy link
Collaborator Author

sam57719 commented May 6, 2024

@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
see this git comment

Ensured all containers on same docker network and told smib-slack what the hostname of the mongo-db container is

sam57719 added 2 commits May 8, 2024 18:42
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.
Copy link
Member

@sjefferson99 sjefferson99 left a 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.

@sjefferson99 sjefferson99 merged commit ada2a45 into develop May 8, 2024
@sjefferson99 sjefferson99 deleted the 11-central-db branch May 8, 2024 18:50
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.

Central DB
2 participants