hisham-cmd commited on
Commit
71b4981
·
verified ·
1 Parent(s): 216cf9b

Update backend with high-quality catalog and fixes

Browse files
Files changed (2) hide show
  1. app/api/seed.py +8 -8
  2. 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 real_products_1000.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_1000.json"),
123
- os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "real_products_1000.json"),
124
- os.path.abspath("real_products_1000.json"),
125
- os.path.abspath("backend/real_products_1000.json"),
126
- "/app/real_products_1000.json",
127
- "/app/backend/real_products_1000.json"
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 real_products_1000.json not found in attempted paths."},
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 real_products_1000.json...")
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: