Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
|
@@ -506,6 +506,14 @@ async def face_swap_api(
|
|
| 506 |
selected_media_clicks_col = ai_enhancer_media_clicks_col
|
| 507 |
elif normalized_appname == "collage-maker" and collage_media_clicks_col is not None:
|
| 508 |
selected_media_clicks_col = collage_media_clicks_col
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
|
| 510 |
# ---------------------------------------------------------
|
| 511 |
# REQUEST TRACE LOG
|
|
@@ -573,11 +581,16 @@ async def face_swap_api(
|
|
| 573 |
raise HTTPException(400, "Invalid new_subcategory_id format.")
|
| 574 |
|
| 575 |
# 1. Find subcategory asset by asset_images._id
|
| 576 |
-
subcat_doc = await subcategories_col.find_one(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
{"asset_images._id": asset_oid},
|
| 578 |
-
{"asset_images.$": 1}
|
| 579 |
)
|
| 580 |
|
|
|
|
| 581 |
if not subcat_doc or "asset_images" not in subcat_doc:
|
| 582 |
await log_faceswap_hit(user_email, "error", start_time, datetime.now(timezone.utc), appname=normalized_appname)
|
| 583 |
raise HTTPException(
|
|
|
|
| 506 |
selected_media_clicks_col = ai_enhancer_media_clicks_col
|
| 507 |
elif normalized_appname == "collage-maker" and collage_media_clicks_col is not None:
|
| 508 |
selected_media_clicks_col = collage_media_clicks_col
|
| 509 |
+
# ---------------------------------------------------------
|
| 510 |
+
# ACTIVE SUBCATEGORY COLLECTION (CRITICAL FIX)
|
| 511 |
+
# ---------------------------------------------------------
|
| 512 |
+
if normalized_appname == "ai-enhancer" and ai_enhancer_db is not None:
|
| 513 |
+
active_subcategories_col = ai_enhancer_db.subcategories
|
| 514 |
+
else:
|
| 515 |
+
active_subcategories_col = subcategories_col
|
| 516 |
+
|
| 517 |
|
| 518 |
# ---------------------------------------------------------
|
| 519 |
# REQUEST TRACE LOG
|
|
|
|
| 581 |
raise HTTPException(400, "Invalid new_subcategory_id format.")
|
| 582 |
|
| 583 |
# 1. Find subcategory asset by asset_images._id
|
| 584 |
+
# subcat_doc = await subcategories_col.find_one(
|
| 585 |
+
# {"asset_images._id": asset_oid},
|
| 586 |
+
# {"asset_images.$": 1} # Only need the asset image URL
|
| 587 |
+
# )
|
| 588 |
+
subcat_doc = await active_subcategories_col.find_one(
|
| 589 |
{"asset_images._id": asset_oid},
|
| 590 |
+
{"asset_images.$": 1}
|
| 591 |
)
|
| 592 |
|
| 593 |
+
|
| 594 |
if not subcat_doc or "asset_images" not in subcat_doc:
|
| 595 |
await log_faceswap_hit(user_email, "error", start_time, datetime.now(timezone.utc), appname=normalized_appname)
|
| 596 |
raise HTTPException(
|