Sfoglia il codice sorgente

增加新热事件原因

xueyiming 5 giorni fa
parent
commit
8d9f824aa7
2 ha cambiato i file con 13 aggiunte e 3 eliminazioni
  1. 9 1
      app/services/demand_pool_service.py
  2. 4 2
      frontend/src/App.tsx

+ 9 - 1
app/services/demand_pool_service.py

@@ -47,9 +47,17 @@ def _reason_from_ext_info(value: object) -> str | None:
     return text_value or None
 
 
+def _hot_demand_pool_strategy() -> str:
+    return (settings.hot_demand_pool_strategy or "新热事件").strip() or "新热事件"
+
+
 def _enrich_demand_pool_item(row: dict[str, object]) -> dict[str, object]:
     item = dict(row)
-    item["reason"] = _reason_from_ext_info(item.get("ext_info"))
+    strategy = str(item.get("strategy") or "").strip()
+    if strategy == _hot_demand_pool_strategy():
+        item["reason"] = _reason_from_ext_info(item.get("ext_info"))
+    else:
+        item["reason"] = None
     return item
 
 

+ 4 - 2
frontend/src/App.tsx

@@ -503,7 +503,8 @@ function DemandPoolPanel() {
         dataIndex: "reason",
         width: 140,
         ellipsis: true,
-        render: (v) => v ?? "",
+        render: (v, record) =>
+          (record.strategy ?? "").trim() === HOT_DEMAND_POOL_STRATEGY ? (v ?? "") : "",
       },
       {
         title: "操作",
@@ -517,7 +518,8 @@ function DemandPoolPanel() {
           const demandName = (record.demand_name ?? "").trim();
           const demandType = (record.type ?? "").trim();
           const dt = (record.dt ?? "").trim();
-          if (!demandName || !demandType || !dt) {
+          const reason = (record.reason ?? "").trim();
+          if (!demandName || !demandType || !dt || reason) {
             return "-";
           }
           return (