Upload 182 files
Browse files- backend/logs/app.log +10 -0
- backend/scripts/migrate_textures_case.py +113 -0
backend/logs/app.log
CHANGED
|
@@ -5208,3 +5208,13 @@ RuntimeError: Both Gradio Spaces failed.
|
|
| 5208 |
2026-05-11 21:24:59,154 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a029d8b0918a81303de0d03, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a029d8b0918a81303de0d03"}, "remainingTimeMS": 29}
|
| 5209 |
2026-05-11 21:40:04,778 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a114e143b18e2c2e46c8, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a114e143b18e2c2e46c8"}, "remainingTimeMS": 29}
|
| 5210 |
2026-05-11 21:40:05,867 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a115e143b18e2c2e46c9, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a115e143b18e2c2e46c9"}, "remainingTimeMS": 29}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5208 |
2026-05-11 21:24:59,154 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a029d8b0918a81303de0d03, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a029d8b0918a81303de0d03"}, "remainingTimeMS": 29}
|
| 5209 |
2026-05-11 21:40:04,778 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a114e143b18e2c2e46c8, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a114e143b18e2c2e46c8"}, "remainingTimeMS": 29}
|
| 5210 |
2026-05-11 21:40:05,867 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a115e143b18e2c2e46c9, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a115e143b18e2c2e46c9"}, "remainingTimeMS": 29}
|
| 5211 |
+
2026-05-11 21:46:09,477 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a281ff1e49d9c28f7695, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a281ff1e49d9c28f7695"}, "remainingTimeMS": 29}
|
| 5212 |
+
2026-05-11 21:46:16,536 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a288f90e330b3179de27, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a288f90e330b3179de27"}, "remainingTimeMS": 29}
|
| 5213 |
+
2026-05-11 21:46:17,577 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a289f90e330b3179de28, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a289f90e330b3179de28"}, "remainingTimeMS": 29}
|
| 5214 |
+
2026-05-11 21:47:09,901 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a2bda0a2f71661c7b112, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a2bda0a2f71661c7b112"}, "remainingTimeMS": 29}
|
| 5215 |
+
2026-05-11 21:47:10,936 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a2bea0a2f71661c7b113, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a2bea0a2f71661c7b113"}, "remainingTimeMS": 29}
|
| 5216 |
+
2026-05-11 21:49:09,831 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a33516532d6089e0e139, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a33516532d6089e0e139"}, "remainingTimeMS": 29}
|
| 5217 |
+
2026-05-11 21:49:10,788 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a33616532d6089e0e13a, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a33616532d6089e0e13a"}, "remainingTimeMS": 29}
|
| 5218 |
+
2026-05-11 21:50:09,487 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a371f53852099a1aed16, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a371f53852099a1aed16"}, "remainingTimeMS": 29}
|
| 5219 |
+
2026-05-11 21:50:16,933 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a378b6b31aba4a4c1c52, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a378b6b31aba4a4c1c52"}, "remainingTimeMS": 29}
|
| 5220 |
+
2026-05-11 21:50:17,879 INFO pymongo.serverSelection: {"message": "Waiting for suitable server to become available", "selector": "Primary()", "operation": "count", "topologyDescription": "<TopologyDescription id: 6a02a379b6b31aba4a4c1c53, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-tynjizz-shard-00-00.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-01.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('ac-tynjizz-shard-00-02.n9htwoa.mongodb.net', 27017) server_type: Unknown, rtt: None>]>", "clientId": {"$oid": "6a02a379b6b31aba4a4c1c53"}, "remainingTimeMS": 29}
|
backend/scripts/migrate_textures_case.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Script de migración: reemplaza referencias con `Texture_wpc_deck` por `Texture_WPC_DECK`
|
| 3 |
+
Uso:
|
| 4 |
+
- Configura `MONGODB_URI` como variable de entorno o edita la constante abajo.
|
| 5 |
+
- Ejecuta: `python backend/scripts/migrate_textures_case.py`
|
| 6 |
+
|
| 7 |
+
Qué hace:
|
| 8 |
+
- Actualiza campos `textura` y `url_preview` dentro de documentos en la colección `catalog`.
|
| 9 |
+
- Busca y reemplaza tanto la ruta dentro de strings como partes de arrays/objetos anidados.
|
| 10 |
+
- Muestra un resumen de documentos inspeccionados y modificados.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import os
|
| 14 |
+
import re
|
| 15 |
+
import sys
|
| 16 |
+
import certifi
|
| 17 |
+
from pymongo import MongoClient
|
| 18 |
+
|
| 19 |
+
MONGODB_URI = os.getenv("MONGODB_URI", "mongodb://127.0.0.1:27017")
|
| 20 |
+
DB_NAME = os.getenv("MONGODB_DB", "hyper_reality")
|
| 21 |
+
COL_NAME = os.getenv("MONGODB_COLLECTION", "catalog")
|
| 22 |
+
|
| 23 |
+
# Allow passing the MongoDB URI as a first command-line argument for
|
| 24 |
+
# environments where setting environment variables is inconvenient.
|
| 25 |
+
if len(sys.argv) > 1 and sys.argv[1].strip():
|
| 26 |
+
MONGODB_URI = sys.argv[1].strip()
|
| 27 |
+
|
| 28 |
+
OLD = "Texture_wpc_deck"
|
| 29 |
+
NEW = "Texture_WPC_DECK"
|
| 30 |
+
|
| 31 |
+
regex_old = re.compile(re.escape(OLD), flags=re.IGNORECASE)
|
| 32 |
+
|
| 33 |
+
# Use certifi bundle to verify Atlas TLS certificates on systems without
|
| 34 |
+
# a proper CA store configured (common in some Windows Python installs).
|
| 35 |
+
client = MongoClient(MONGODB_URI, tls=True, tlsCAFile=certifi.where())
|
| 36 |
+
db = client[DB_NAME]
|
| 37 |
+
col = db[COL_NAME]
|
| 38 |
+
|
| 39 |
+
def replace_in_value(val):
|
| 40 |
+
if isinstance(val, str):
|
| 41 |
+
if regex_old.search(val):
|
| 42 |
+
return regex_old.sub(NEW, val)
|
| 43 |
+
return val
|
| 44 |
+
if isinstance(val, list):
|
| 45 |
+
changed = False
|
| 46 |
+
out = []
|
| 47 |
+
for v in val:
|
| 48 |
+
nv = replace_in_value(v)
|
| 49 |
+
if nv != v:
|
| 50 |
+
changed = True
|
| 51 |
+
out.append(nv)
|
| 52 |
+
return out if changed else val
|
| 53 |
+
if isinstance(val, dict):
|
| 54 |
+
changed = False
|
| 55 |
+
out = {}
|
| 56 |
+
for k, v in val.items():
|
| 57 |
+
nv = replace_in_value(v)
|
| 58 |
+
if nv != v:
|
| 59 |
+
changed = True
|
| 60 |
+
out[k] = nv
|
| 61 |
+
return out if changed else val
|
| 62 |
+
return val
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def migrate_batch(batch_size=200):
|
| 66 |
+
total = col.count_documents({})
|
| 67 |
+
print(f"Documentos totales en {DB_NAME}.{COL_NAME}: {total}")
|
| 68 |
+
cursor = col.find({})
|
| 69 |
+
modified = 0
|
| 70 |
+
inspected = 0
|
| 71 |
+
for doc in cursor:
|
| 72 |
+
inspected += 1
|
| 73 |
+
doc_id = doc.get("_id")
|
| 74 |
+
new_doc = False
|
| 75 |
+
updates = {}
|
| 76 |
+
# Revisa productos list si existe
|
| 77 |
+
productos = doc.get("productos")
|
| 78 |
+
if productos:
|
| 79 |
+
new_productos = []
|
| 80 |
+
changed_any = False
|
| 81 |
+
for p in productos:
|
| 82 |
+
new_p = dict(p)
|
| 83 |
+
for field in ["textura", "url_preview"]:
|
| 84 |
+
if field in new_p and isinstance(new_p[field], str) and regex_old.search(new_p[field]):
|
| 85 |
+
new_p[field] = regex_old.sub(NEW, new_p[field])
|
| 86 |
+
changed_any = True
|
| 87 |
+
new_productos.append(new_p)
|
| 88 |
+
if changed_any:
|
| 89 |
+
updates["productos"] = new_productos
|
| 90 |
+
new_doc = True
|
| 91 |
+
|
| 92 |
+
# Revisa cualquier otro campo a nivel superior (por si hay url_preview fuera de productos)
|
| 93 |
+
for key, value in doc.items():
|
| 94 |
+
if key in ["productos", "_id"]:
|
| 95 |
+
continue
|
| 96 |
+
new_val = replace_in_value(value)
|
| 97 |
+
if new_val != value:
|
| 98 |
+
updates[key] = new_val
|
| 99 |
+
new_doc = True
|
| 100 |
+
|
| 101 |
+
if new_doc and updates:
|
| 102 |
+
res = col.update_one({"_id": doc_id}, {"$set": updates})
|
| 103 |
+
if res.modified_count:
|
| 104 |
+
modified += 1
|
| 105 |
+
print(f"Modificado doc _id={doc_id}: campos actualizados: {list(updates.keys())}")
|
| 106 |
+
|
| 107 |
+
print(f"Inspeccionados: {inspected}, Modificados: {modified}")
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
if __name__ == "__main__":
|
| 111 |
+
print("Conectando a:", MONGODB_URI)
|
| 112 |
+
migrate_batch()
|
| 113 |
+
client.close()
|