This commit is contained in:
Your Name
2026-04-17 03:36:03 +08:00
parent 3cc36a054c
commit d3223a75a4
5 changed files with 525 additions and 4 deletions

View File

@@ -512,8 +512,27 @@ def create_detect_job_if_needed(limit: int = 1000, created_by: str = "system") -
domain_ids = [row[0] for row in cur.fetchall()]
if not domain_ids:
conn.rollback()
return None
if not domain_ids:
try:
from app.services.sync_push_service import pull_detect_task_batch_now
pull_detect_task_batch_now(limit=max(1, int(limit or 1000)))
except Exception:
pass
with get_db() as conn:
conn.autocommit = False
with conn.cursor() as cur:
cur.execute(_selection_sql(), (max(1, int(limit or 1000)),))
domain_ids = [row[0] for row in cur.fetchall()]
if not domain_ids:
conn.rollback()
return None
with get_db() as conn:
conn.autocommit = False
with conn.cursor() as cur:
job_code = f"detect-{datetime.now().strftime('%Y%m%d%H%M%S')}-{uuid4().hex[:6]}"
plan_hash = uuid4().hex
cur.execute(