Spaces:
Sleeping
Sleeping
Added upate_chatbot_id.py file
Browse files- test_endpoint.py +0 -1
- update_chatbot_id.py +17 -0
test_endpoint.py
CHANGED
|
@@ -23,7 +23,6 @@ resp = requests.post(f"{BASE_URL}/auth/register", json=register_data)
|
|
| 23 |
print("Register Response:")
|
| 24 |
safe_print_response(resp)
|
| 25 |
|
| 26 |
-
# 2️⃣ Login to get JWT token
|
| 27 |
login_data = {
|
| 28 |
"email": "test@example.com",
|
| 29 |
"password": "test"
|
|
|
|
| 23 |
print("Register Response:")
|
| 24 |
safe_print_response(resp)
|
| 25 |
|
|
|
|
| 26 |
login_data = {
|
| 27 |
"email": "test@example.com",
|
| 28 |
"password": "test"
|
update_chatbot_id.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
from motor.motor_asyncio import AsyncIOMotorClient
|
| 3 |
+
from app.config import settings
|
| 4 |
+
|
| 5 |
+
async def rename_field():
|
| 6 |
+
client = AsyncIOMotorClient(settings.mongo_uri)
|
| 7 |
+
db = client[settings.mongo_db_name]
|
| 8 |
+
chat_logs = db["ChatLogs"]
|
| 9 |
+
|
| 10 |
+
result = await chat_logs.update_many(
|
| 11 |
+
{"chatbot": {"$exists": True}}, # filter documents where "chatbot" exists
|
| 12 |
+
{"$rename": {"chatbot": "chatbot_id"}} # rename field
|
| 13 |
+
)
|
| 14 |
+
print(f"Matched {result.matched_count}, Modified {result.modified_count} documents.")
|
| 15 |
+
|
| 16 |
+
if __name__ == "__main__":
|
| 17 |
+
asyncio.run(rename_field())
|