Spaces:
Sleeping
Sleeping
Update backend with high-quality catalog and fixes
Browse files- app/api/seed.py +8 -8
- app/main.py +1 -1
app/api/seed.py
CHANGED
|
@@ -117,14 +117,14 @@ async def seed_database(clear: bool = False, db: Session = Depends(get_db)):
|
|
| 117 |
db.add(admin_user)
|
| 118 |
db.commit()
|
| 119 |
|
| 120 |
-
# Search for
|
| 121 |
possible_paths = [
|
| 122 |
-
os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "backend", "
|
| 123 |
-
os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "
|
| 124 |
-
os.path.abspath("
|
| 125 |
-
os.path.abspath("backend/
|
| 126 |
-
"/app/
|
| 127 |
-
"/app/backend/
|
| 128 |
]
|
| 129 |
|
| 130 |
json_path = None
|
|
@@ -136,7 +136,7 @@ async def seed_database(clear: bool = False, db: Session = Depends(get_db)):
|
|
| 136 |
if not json_path:
|
| 137 |
return AuthResponse(
|
| 138 |
isSuccess=False,
|
| 139 |
-
value={"message": f"Source file
|
| 140 |
statusCode=404,
|
| 141 |
error="File not found"
|
| 142 |
)
|
|
|
|
| 117 |
db.add(admin_user)
|
| 118 |
db.commit()
|
| 119 |
|
| 120 |
+
# Search for real_products_200.json in multiple likely locations
|
| 121 |
possible_paths = [
|
| 122 |
+
os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "backend", "real_products_200.json"),
|
| 123 |
+
os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "real_products_200.json"),
|
| 124 |
+
os.path.abspath("real_products_200.json"),
|
| 125 |
+
os.path.abspath("backend/real_products_200.json"),
|
| 126 |
+
"/app/real_products_200.json",
|
| 127 |
+
"/app/backend/real_products_200.json"
|
| 128 |
]
|
| 129 |
|
| 130 |
json_path = None
|
|
|
|
| 136 |
if not json_path:
|
| 137 |
return AuthResponse(
|
| 138 |
isSuccess=False,
|
| 139 |
+
value={"message": f"Source file real_products_200.json not found in attempted paths."},
|
| 140 |
statusCode=404,
|
| 141 |
error="File not found"
|
| 142 |
)
|
app/main.py
CHANGED
|
@@ -77,7 +77,7 @@ def create_app() -> FastAPI:
|
|
| 77 |
# Check if we have any products
|
| 78 |
count = db.query(Product).count()
|
| 79 |
if count == 0:
|
| 80 |
-
print(">>> [BOOTSTRAP] Database is empty. Auto-seeding from
|
| 81 |
await seed_database(clear=False, db=db)
|
| 82 |
print(">>> [BOOTSTRAP] Seeding complete.")
|
| 83 |
else:
|
|
|
|
| 77 |
# Check if we have any products
|
| 78 |
count = db.query(Product).count()
|
| 79 |
if count == 0:
|
| 80 |
+
print(">>> [BOOTSTRAP] Database is empty. Auto-seeding from real_products_200.json...")
|
| 81 |
await seed_database(clear=False, db=db)
|
| 82 |
print(">>> [BOOTSTRAP] Seeding complete.")
|
| 83 |
else:
|