|
@@ -147,7 +147,7 @@ async def update_image_modified_json(
|
|
|
cursor = db_conn.cursor(dictionary=True)
|
|
cursor = db_conn.cursor(dictionary=True)
|
|
|
|
|
|
|
|
# 1️ 获取图片信息
|
|
# 1️ 获取图片信息
|
|
|
- cursor.execute(f"SELECT image_type FROM {settings.DB_IMAGE_TABLE_NAME} WHERE id = %s", (id,))
|
|
|
|
|
|
|
+ cursor.execute(f"SELECT image_type, card_id FROM {settings.DB_IMAGE_TABLE_NAME} WHERE id = %s", (id,))
|
|
|
row = cursor.fetchone()
|
|
row = cursor.fetchone()
|
|
|
if not row:
|
|
if not row:
|
|
|
raise HTTPException(status_code=404, detail=f"ID为 {id} 的图片未找到。")
|
|
raise HTTPException(status_code=404, detail=f"ID为 {id} 的图片未找到。")
|
|
@@ -158,6 +158,7 @@ async def update_image_modified_json(
|
|
|
if not score_type:
|
|
if not score_type:
|
|
|
raise HTTPException(status_code=400, detail=f"未知的 image_type: {image_type}")
|
|
raise HTTPException(status_code=400, detail=f"未知的 image_type: {image_type}")
|
|
|
|
|
|
|
|
|
|
+ logger.info("开始计算分数")
|
|
|
# 2️ 调用远程计算接口
|
|
# 2️ 调用远程计算接口
|
|
|
try:
|
|
try:
|
|
|
response = await run_in_threadpool(
|
|
response = await run_in_threadpool(
|
|
@@ -173,6 +174,7 @@ async def update_image_modified_json(
|
|
|
logger.error(f"分数计算接口返回错误: {response.status_code}, {response.text}")
|
|
logger.error(f"分数计算接口返回错误: {response.status_code}, {response.text}")
|
|
|
raise HTTPException(status_code=response.status_code,
|
|
raise HTTPException(status_code=response.status_code,
|
|
|
detail=f"分数计算接口返回错误: {response.text}")
|
|
detail=f"分数计算接口返回错误: {response.text}")
|
|
|
|
|
+ logger.info("分数计算完成")
|
|
|
|
|
|
|
|
# 3️ 保存结果到数据库
|
|
# 3️ 保存结果到数据库
|
|
|
recalculated_json_str = json.dumps(response.json(), ensure_ascii=False)
|
|
recalculated_json_str = json.dumps(response.json(), ensure_ascii=False)
|