Просмотр исходного кода

fix(realtime-control): include open-ended ads in day pause

刘立冬 2 дней назад
Родитель
Сommit
b3fcf16fd6

+ 8 - 2
examples/tencent_realtime_control/operator_control.py

@@ -91,6 +91,11 @@ def _next_delivery_start(now: datetime, start_hour: int) -> datetime:
     )
 
 
+def _delivery_end_allows_day(raw_end_date: Any, target_date: str) -> bool:
+    end_date = str(raw_end_date or "").strip()
+    return end_date in {"", "0"} or end_date >= target_date
+
+
 def _load_today_metrics(
     client: TencentClient,
     account_id: int,
@@ -164,8 +169,9 @@ def preview_write_command(
                         )
                         and (
                             parsed.action == ACTION_STOP
-                            or not str(ad.get("end_date") or "")
-                            or str(ad.get("end_date")) >= next_day
+                            or _delivery_end_allows_day(
+                                ad.get("end_date"), next_day
+                            )
                         )
                         and (
                             parsed.action == ACTION_STOP

+ 1 - 0
examples/tencent_realtime_control/test_feishu_natural_commands.py

@@ -195,6 +195,7 @@ class PreviewSnapshotTest(unittest.TestCase):
                         "adgroup_name": "active",
                         "configured_status": "AD_STATUS_NORMAL",
                         "begin_date": "2026-07-01",
+                        "end_date": "0",
                     },
                     {
                         "adgroup_id": 102,