feat: MyVibe settings and memory leak fix.

This commit is contained in:
Lemon4ksan
2025-01-30 20:08:46 +03:00
parent c353de429f
commit b3962c8928
9 changed files with 455 additions and 245 deletions

View File

@@ -1,6 +1,6 @@
"""This documents initialises databse and contains methods to access it."""
from typing import cast
from typing import Any, cast
from pymongo import MongoClient
from pymongo.collection import Collection
@@ -29,15 +29,20 @@ class BaseUsersDatabase:
queue_page=0,
vibe_batch_id=None,
vibe_type=None,
vibe_id=None
vibe_id=None,
vibe_settings={
'mood': 'all',
'diversity': 'default',
'lang': 'any'
}
))
def update(self, uid: int, data: User) -> None:
def update(self, uid: int, data: User | dict[Any, Any]) -> None:
"""Update user record.
Args:
uid (int): User id.
data (dict[Any, Any]): Updated data.
data (User | dict[Any, Any]): Updated data.
"""
self.get_user(uid)
users.update_one({'_id': uid}, {"$set": data})
@@ -65,7 +70,12 @@ class BaseUsersDatabase:
queue_page=0,
vibe_batch_id=None,
vibe_type=None,
vibe_id=None
vibe_id=None,
vibe_settings={
'mood': 'all',
'diversity': 'default',
'lang': 'any'
}
)
for field, default_value in fields.items():
if field not in existing_fields: