feat: when database_type embedded setup initial data for testing the system
Browse files
app/core/initial_setup/setup.py
CHANGED
|
@@ -34,14 +34,18 @@ class InitialSetup:
|
|
| 34 |
async def setup(self) -> None:
|
| 35 |
"""Setup initial data if database type is embedded"""
|
| 36 |
try:
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
chat_completions = self._load_initial_data()
|
| 47 |
logger.info(f"Loaded {len(chat_completions)} initial chat completions")
|
|
|
|
| 34 |
async def setup(self) -> None:
|
| 35 |
"""Setup initial data if database type is embedded"""
|
| 36 |
try:
|
| 37 |
+
if db_config.DATABASE_TYPE != "embedded":
|
| 38 |
+
logger.info("Skipping initial setup as database type is not embedded")
|
| 39 |
+
return
|
| 40 |
|
| 41 |
+
# if MONGO_URI is not set, it means we are using embedded database
|
| 42 |
+
# last check is for the case of using mongomock-motor for database_type=embedded
|
| 43 |
+
# so last exit before the bridge :) turkish joke
|
| 44 |
+
if db_config.MONGO_URI is None:
|
| 45 |
+
# delete all chat completions in the embedded database
|
| 46 |
+
logger.warning("Deleting all chat completions in the embedded database")
|
| 47 |
+
await self.chat_repository.db.chat_completion.delete_many({})
|
| 48 |
+
logger.warning("Deleting all chat completions in the embedded database done")
|
| 49 |
|
| 50 |
chat_completions = self._load_initial_data()
|
| 51 |
logger.info(f"Loaded {len(chat_completions)} initial chat completions")
|