Add AutoCora auto-submit for today's tasks and fix pipeline issues
- Auto-submit Cora jobs for tasks due today on each autocora loop cycle - Move ClickUp tasks to "automation underway" at submission time - Default to blank URL for tasks missing IMSURL (new content) - Use task Keyword field as project_name in folder watcher (not task name) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>fix/customer-field-migration
parent
bc64fae6f1
commit
ada28d1655
|
|
@ -521,7 +521,7 @@ class Scheduler:
|
||||||
# ── AutoCora Result Polling ──
|
# ── AutoCora Result Polling ──
|
||||||
|
|
||||||
def _autocora_loop(self):
|
def _autocora_loop(self):
|
||||||
"""Poll for AutoCora results on a regular interval."""
|
"""Auto-submit jobs for today's tasks, then poll for results."""
|
||||||
interval = self.config.autocora.poll_interval_minutes * 60
|
interval = self.config.autocora.poll_interval_minutes * 60
|
||||||
|
|
||||||
# Wait before first poll
|
# Wait before first poll
|
||||||
|
|
@ -529,6 +529,7 @@ class Scheduler:
|
||||||
|
|
||||||
while not self._stop_event.is_set():
|
while not self._stop_event.is_set():
|
||||||
try:
|
try:
|
||||||
|
self._auto_submit_cora_jobs()
|
||||||
self._poll_autocora_results()
|
self._poll_autocora_results()
|
||||||
self.db.kv_set(
|
self.db.kv_set(
|
||||||
"system:loop:autocora:last_run", datetime.now(UTC).isoformat()
|
"system:loop:autocora:last_run", datetime.now(UTC).isoformat()
|
||||||
|
|
@ -537,6 +538,22 @@ class Scheduler:
|
||||||
log.error("AutoCora poll error: %s", e)
|
log.error("AutoCora poll error: %s", e)
|
||||||
self._interruptible_wait(interval, self._force_autocora)
|
self._interruptible_wait(interval, self._force_autocora)
|
||||||
|
|
||||||
|
def _auto_submit_cora_jobs(self):
|
||||||
|
"""Auto-submit AutoCora jobs for tasks due today."""
|
||||||
|
from .tools.autocora import submit_autocora_jobs
|
||||||
|
|
||||||
|
if not self.config.clickup.api_token:
|
||||||
|
return
|
||||||
|
|
||||||
|
today = datetime.now(UTC).strftime("%Y-%m-%d")
|
||||||
|
ctx = {
|
||||||
|
"config": self.config,
|
||||||
|
"db": self.db,
|
||||||
|
"agent": self.agent,
|
||||||
|
}
|
||||||
|
result = submit_autocora_jobs(target_date=today, ctx=ctx)
|
||||||
|
log.info("AutoCora auto-submit (%s): %s", today, result)
|
||||||
|
|
||||||
def _poll_autocora_results(self):
|
def _poll_autocora_results(self):
|
||||||
"""Check for completed AutoCora results and update ClickUp tasks."""
|
"""Check for completed AutoCora results and update ClickUp tasks."""
|
||||||
from .tools.autocora import _parse_result
|
from .tools.autocora import _parse_result
|
||||||
|
|
@ -757,7 +774,7 @@ class Scheduler:
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
"xlsx_path": str(xlsx_path),
|
"xlsx_path": str(xlsx_path),
|
||||||
"project_name": matched_task.name,
|
"project_name": matched_task.custom_fields.get("Keyword", "") or matched_task.name,
|
||||||
"money_site_url": money_site_url,
|
"money_site_url": money_site_url,
|
||||||
"custom_anchors": matched_task.custom_fields.get("CustomAnchors", "") or "",
|
"custom_anchors": matched_task.custom_fields.get("CustomAnchors", "") or "",
|
||||||
"cli_flags": matched_task.custom_fields.get("CLIFlags", "") or "",
|
"cli_flags": matched_task.custom_fields.get("CLIFlags", "") or "",
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,7 @@ def _group_by_keyword(tasks, all_tasks):
|
||||||
url = task.custom_fields.get("IMSURL", "") or ""
|
url = task.custom_fields.get("IMSURL", "") or ""
|
||||||
url = str(url).strip()
|
url = str(url).strip()
|
||||||
if not url:
|
if not url:
|
||||||
alerts.append(f"Task '{task.name}' (id={task.id}) missing IMSURL field")
|
url = "https://seotoollab.com/blank.html"
|
||||||
continue
|
|
||||||
|
|
||||||
kw_lower = keyword.lower()
|
kw_lower = keyword.lower()
|
||||||
if kw_lower not in groups:
|
if kw_lower not in groups:
|
||||||
|
|
@ -251,6 +250,10 @@ def submit_autocora_jobs(target_date: str = "", ctx: dict | None = None) -> str:
|
||||||
}
|
}
|
||||||
db.kv_set(kv_key, json.dumps(kv_state))
|
db.kv_set(kv_key, json.dumps(kv_state))
|
||||||
|
|
||||||
|
# Move ClickUp tasks to "automation underway"
|
||||||
|
for tid in group["task_ids"]:
|
||||||
|
client.update_task_status(tid, "automation underway")
|
||||||
|
|
||||||
submitted.append(group["keyword"])
|
submitted.append(group["keyword"])
|
||||||
log.info("Submitted AutoCora job: %s → %s", group["keyword"], job_id)
|
log.info("Submitted AutoCora job: %s → %s", group["keyword"], job_id)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue