fix: 6 bug fixes - timezone CST, knowledge_ids mismatch, skill uninstall, dashboard stats, chat knowledge retrieval, skill selection
This commit is contained in:
1 parent
f7ab61bd9d
commit
8ec808b515
6 files changed
+119
-49
No files matched your search
@@ -359,7 +359,9 @@ def uninstall_app(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""卸载应用 - 删除当前用户的安装记录(按用户隔离)"""
|
||||
"""卸载应用 - 删除当前用户的安装记录(按用户隔离)
|
||||
修复: 当没有AppInstallation记录时(如导入的技能),仍然允许卸载
|
||||
"""
|
||||
app = db.query(MarketApp).filter(MarketApp.id == app_id).first()
|
||||
if not app:
|
||||
raise HTTPException(status_code=404, detail="应用不存在")
|
||||
@@ -368,22 +370,26 @@ def uninstall_app(
|
||||
installation = db.query(AppInstallation).filter(
|
||||
and_(AppInstallation.app_id == app_id, AppInstallation.user_id == current_user.id)
|
||||
).first()
|
||||
if not installation:
|
||||
raise HTTPException(status_code=400, detail="应用未安装")
|
||||
|
||||
# 删除安装记录
|
||||
db.delete(installation)
|
||||
# 修复: 即使没有安装记录也允许卸载(导入的技能可能没有安装记录)
|
||||
if installation:
|
||||
db.delete(installation)
|
||||
|
||||
# 问题4修复: 将AppPurchase状态从installed重置为purchased
|
||||
purchase = db.query(AppPurchase).filter(
|
||||
and_(AppPurchase.app_id == app_id, AppPurchase.user_id == current_user.id)
|
||||
).first()
|
||||
if purchase and purchase.status == "installed":
|
||||
purchase.status = "purchased"
|
||||
# 将AppPurchase状态从installed重置为purchased
|
||||
purchase = db.query(AppPurchase).filter(
|
||||
and_(AppPurchase.app_id == app_id, AppPurchase.user_id == current_user.id)
|
||||
).first()
|
||||
if purchase and purchase.status == "installed":
|
||||
purchase.status = "purchased"
|
||||
|
||||
# 更新应用安装量(减1,最小为0)
|
||||
if app.install_count and app.install_count > 0:
|
||||
app.install_count = app.install_count - 1
|
||||
|
||||
# 将应用状态标记为未安装(对于skill类型)
|
||||
if app.type == "skill" and app.is_active:
|
||||
app.is_active = False
|
||||
|
||||
# 更新应用安装量(减1,最小为0)
|
||||
if app.install_count and app.install_count > 0:
|
||||
app.install_count = app.install_count - 1
|
||||
app.updated_at = datetime.now()
|
||||
|
||||
db.commit()
|
||||
|
||||
Reference in new issue
Block a user