Merge branch 'release/v0.2.4' of github.com:SuanmoSuanyangTechnology/MemoryBear into release/v0.2.4
This commit is contained in:
@@ -124,17 +124,17 @@ class EmotionAnalyticsService:
|
|||||||
# 将查询结果转换为字典,方便查找
|
# 将查询结果转换为字典,方便查找
|
||||||
tags_dict = {tag["emotion_type"]: tag for tag in tags}
|
tags_dict = {tag["emotion_type"]: tag for tag in tags}
|
||||||
|
|
||||||
# 补全缺失的情绪维度,并翻译 emotion_type
|
# 补全缺失的情绪维度,直接使用英文枚举key(前端自行翻译)
|
||||||
complete_tags = []
|
complete_tags = []
|
||||||
for emotion in all_emotion_types:
|
for emotion in all_emotion_types:
|
||||||
if emotion in tags_dict:
|
if emotion in tags_dict:
|
||||||
tag = tags_dict[emotion].copy()
|
tag = tags_dict[emotion].copy()
|
||||||
tag["emotion_type"] = self._translate_emotion_type(emotion, language)
|
tag["emotion_type"] = emotion
|
||||||
complete_tags.append(tag)
|
complete_tags.append(tag)
|
||||||
else:
|
else:
|
||||||
# 如果该情绪类型不存在,添加默认值
|
# 如果该情绪类型不存在,添加默认值
|
||||||
complete_tags.append({
|
complete_tags.append({
|
||||||
"emotion_type": self._translate_emotion_type(emotion, language),
|
"emotion_type": emotion,
|
||||||
"count": 0,
|
"count": 0,
|
||||||
"percentage": 0.0,
|
"percentage": 0.0,
|
||||||
"avg_intensity": 0.0
|
"avg_intensity": 0.0
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ def get_workspace_end_users(
|
|||||||
) -> List[EndUser]:
|
) -> List[EndUser]:
|
||||||
"""获取工作空间的所有宿主(优化版本:减少数据库查询次数)
|
"""获取工作空间的所有宿主(优化版本:减少数据库查询次数)
|
||||||
|
|
||||||
返回结果按 updated_at 从新到旧排序(NULL 值排在最后)
|
返回结果按 created_at 从新到旧排序(NULL 值排在最后)
|
||||||
"""
|
"""
|
||||||
business_logger.info(f"获取工作空间宿主列表: workspace_id={workspace_id}, 操作者: {current_user.username}")
|
business_logger.info(f"获取工作空间宿主列表: workspace_id={workspace_id}, 操作者: {current_user.username}")
|
||||||
|
|
||||||
@@ -71,13 +71,13 @@ def get_workspace_end_users(
|
|||||||
app_ids = [app.id for app in apps_orm]
|
app_ids = [app.id for app in apps_orm]
|
||||||
|
|
||||||
# 批量查询所有 end_users(一次查询而非循环查询)
|
# 批量查询所有 end_users(一次查询而非循环查询)
|
||||||
# 按 updated_at 降序排序,NULL 值排在最后;id 作为次级排序键保证确定性
|
# 按 created_at 降序排序,NULL 值排在最后;id 作为次级排序键保证确定性
|
||||||
from app.models.end_user_model import EndUser as EndUserModel
|
from app.models.end_user_model import EndUser as EndUserModel
|
||||||
from sqlalchemy import desc, nullslast
|
from sqlalchemy import desc, nullslast
|
||||||
end_users_orm = db.query(EndUserModel).filter(
|
end_users_orm = db.query(EndUserModel).filter(
|
||||||
EndUserModel.app_id.in_(app_ids)
|
EndUserModel.app_id.in_(app_ids)
|
||||||
).order_by(
|
).order_by(
|
||||||
nullslast(desc(EndUserModel.updated_at)),
|
nullslast(desc(EndUserModel.created_at)),
|
||||||
desc(EndUserModel.id)
|
desc(EndUserModel.id)
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user