mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 00:40:45 +08:00
fix(scheduler): default scheduled job timezone to system timezone
Replace hardcoded Asia/Shanghai with host IANA timezone detection for new scheduled jobs across tools, admin API, gateway cron, and store layer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a27bca5648
commit
a8d3d2d5ec
8 changed files with 256 additions and 11 deletions
|
|
@ -170,7 +170,7 @@ class AssistantStoreProtocol(Protocol):
|
|||
def todo_create(self, *, tenant_id: 'str', owner_user_id: 'str', title: 'str', due_at: 'str | None' = None, assignee_user_id: 'str | None' = None) -> 'dict[str, Any]': ...
|
||||
def todo_list(self, *, tenant_id: 'str', assignee_user_id: 'str | None' = None, status: 'str | None' = 'open', limit: 'int' = 50) -> 'list[dict[str, Any]]': ...
|
||||
def todo_set_status(self, *, tenant_id: 'str', todo_id: 'str', status: 'str') -> 'bool': ...
|
||||
def scheduled_job_create(self, *, tenant_id: 'str', name: 'str', prompt_text: 'str', schedule_kind: 'str', schedule_expr: 'str', timezone_name: 'str' = 'Asia/Shanghai', description: 'str' = '', interaction_mode: 'str' = 'expert', specialist: 'str' = 'generalist', lang: 'str' = 'zh', delivery: 'dict[str, Any] | None' = None, source_session_id: 'str | None' = None, created_by_user_id: 'str' = '', source: 'str' = 'admin', status: 'str' = 'active') -> 'Any': ...
|
||||
def scheduled_job_create(self, *, tenant_id: 'str', name: 'str', prompt_text: 'str', schedule_kind: 'str', schedule_expr: 'str', timezone_name: 'str | None' = None, description: 'str' = '', interaction_mode: 'str' = 'expert', specialist: 'str' = 'generalist', lang: 'str' = 'zh', delivery: 'dict[str, Any] | None' = None, source_session_id: 'str | None' = None, created_by_user_id: 'str' = '', source: 'str' = 'admin', status: 'str' = 'active') -> 'Any': ...
|
||||
def scheduled_job_get(self, *, job_id: 'str', tenant_id: 'str | None' = None) -> 'Any | None': ...
|
||||
def scheduled_job_list(self, *, tenant_id: 'str', status: 'str | None' = None, limit: 'int' = 100, offset: 'int' = 0) -> 'list[Any]': ...
|
||||
def scheduled_job_update(self, *, tenant_id: 'str', job_id: 'str', patch: 'dict[str, Any]') -> 'Any | None': ...
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from datetime import datetime, timezone
|
|||
from typing import Any
|
||||
|
||||
from runtime.scheduler.expressions import compute_next_run_at, normalize_schedule_kind
|
||||
from runtime.scheduler.system_timezone import default_system_timezone
|
||||
|
||||
SCHEDULED_JOB_DDL = """
|
||||
CREATE TABLE IF NOT EXISTS scheduled_job (
|
||||
|
|
@ -121,7 +122,7 @@ def _row_to_job(row: Any) -> ScheduledJob:
|
|||
status=str(row["status"] or ""),
|
||||
schedule_kind=str(row["schedule_kind"] or ""),
|
||||
schedule_expr=str(row["schedule_expr"] or ""),
|
||||
timezone=str(row["timezone"] or "Asia/Shanghai"),
|
||||
timezone=str(row["timezone"] or default_system_timezone()),
|
||||
prompt_text=str(row["prompt_text"] or ""),
|
||||
interaction_mode=str(row["interaction_mode"] or "expert"),
|
||||
specialist=str(row["specialist"] or "generalist"),
|
||||
|
|
@ -180,7 +181,7 @@ class ScheduledJobStoreMixin:
|
|||
prompt_text: str,
|
||||
schedule_kind: str,
|
||||
schedule_expr: str,
|
||||
timezone_name: str = "Asia/Shanghai",
|
||||
timezone_name: str | None = None,
|
||||
description: str = "",
|
||||
interaction_mode: str = "expert",
|
||||
specialist: str = "generalist",
|
||||
|
|
@ -194,7 +195,7 @@ class ScheduledJobStoreMixin:
|
|||
jid = str(uuid.uuid4())
|
||||
ts = utc_now_iso()
|
||||
kind = normalize_schedule_kind(schedule_kind)
|
||||
tz = str(timezone_name or "Asia/Shanghai").strip() or "Asia/Shanghai"
|
||||
tz = str(timezone_name or default_system_timezone()).strip() or default_system_timezone()
|
||||
next_run = compute_next_run_at(
|
||||
schedule_kind=kind,
|
||||
schedule_expr=str(schedule_expr or "").strip(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue