feat(schedule): support KOL subscription targets and random time windows
Frontend CI / Frontend (push) Successful in 3m37s
Backend CI / Backend (push) Failing after 6m47s

Extend schedule tasks to dispatch KOL subscription prompts in addition
to prompt rules, add daily/weekly scheduling with fixed or random time
windows, and track dispatch outcomes (last run, status, consecutive
failures).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 23:51:45 +08:00
parent 9cc6537e68
commit c28c4f1419
20 changed files with 3034 additions and 329 deletions
+33 -3
View File
@@ -1675,15 +1675,31 @@ export interface PromptRuleStatusRequest {
// --- Schedule Tasks ---
export type ScheduleTargetType = 'prompt_rule' | 'kol_subscription_prompt'
export type ScheduleKind = 'daily' | 'weekly'
export type ScheduleTimeMode = 'fixed' | 'random_window'
export type ScheduleDispatchStatus = 'success' | 'failed' | string
export interface ScheduleTask {
id: number
workspace_id: number | null
prompt_rule_id: number
target_type: ScheduleTargetType
prompt_rule_id: number | null
prompt_rule_name: string | null
subscription_prompt_id: number | null
subscription_prompt_name: string | null
subscription_package_name: string | null
subscription_kol_name: string | null
brand_id: number | null
brand_name: string | null
name: string
cron_expr: string
schedule_kind: ScheduleKind
schedule_days: string[]
schedule_time_mode: ScheduleTimeMode
random_window_start: string
random_window_end: string
generation_input: Record<string, JsonValue>
auto_publish: boolean
publish_account_ids: string[]
auto_publish_platforms: string[]
@@ -1695,6 +1711,10 @@ export interface ScheduleTask {
end_at: string | null
next_run_at: string | null
status: 'enabled' | 'disabled'
last_run_at: string | null
last_dispatch_status: ScheduleDispatchStatus | null
last_dispatch_error: string | null
consecutive_failures: number
generation_status?: string | null
execution_time?: string | null
generated_articles?: GeneratedArticleLink[] | null
@@ -1703,10 +1723,18 @@ export interface ScheduleTask {
}
export interface ScheduleTaskRequest {
prompt_rule_id: number
target_type?: ScheduleTargetType
prompt_rule_id?: number | null
subscription_prompt_id?: number | null
brand_id?: number | null
name: string
cron_expr: string
cron_expr?: string
schedule_kind?: ScheduleKind
schedule_days?: string[]
schedule_time_mode?: ScheduleTimeMode
random_window_start?: string
random_window_end?: string
generation_input?: Record<string, JsonValue>
auto_publish?: boolean
publish_account_ids?: string[]
cover_asset_url?: string | null
@@ -1721,6 +1749,8 @@ export interface ScheduleTaskListParams {
page?: number
page_size?: number
prompt_rule_id?: number
subscription_prompt_id?: number
target_type?: ScheduleTargetType
status?: string
keyword?: string
created_from?: string