소스 검색

优化查询算法接口

linhaohong 4 달 전
부모
커밋
dec98d045d
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      AdminController/AlgorithmShopManageController.py

+ 10 - 2
AdminController/AlgorithmShopManageController.py

@@ -132,10 +132,18 @@ class AlgorithmShopManageView(View):
                 device_algorithm_explain_qs = DeviceAlgorithmExplain.objects.filter(
                     algorithm_type_id=device_algorithm_type.id)
                 translation_num = device_algorithm_explain_qs.count()
-                device_algorithm_explain = device_algorithm_explain_qs.filter(lang="cn").first()
+                device_algorithm_explain = device_algorithm_explain_qs.filter(lang='cn').values("title")
+                if device_algorithm_explain.exists():
+                    title = device_algorithm_explain[0]["title"]
+                else:
+                    device_algorithm_explain = device_algorithm_explain_qs.values("title")
+                    if device_algorithm_explain.exists():
+                        title = device_algorithm_explain[0]["title"]
+                    else:
+                        title = ""
                 device_algorithm_type_list.append({
                     "algorithmId": device_algorithm_type.id,
-                    "title": device_algorithm_explain.title if device_algorithm_explain.title else "",
+                    "title": title,
                     "algorithmType": device_algorithm_type.type,
                     "memory": device_algorithm_type.memory,
                     "downCount": device_algorithm_type.down_count,