base_url: http://localhost:8899
error_handling:
  notify_on_failure: true
  stop_on_failure: true
scheduler:
  log_level: INFO
  retry:
    delay: 60
    max_attempts: 3
tasks:
  # 每10分钟抓取B站热门视频
  fetch_popular_videos:
    endpoint: /bilibili/popular/all
    method: GET
    name: 获取B站热门视频
    params:
      size: 20
      max_pages: 100
      save_to_db: true
      include_videos: false
    requires: [ ]
    schedule:
      type: interval
      interval_value: 10
      interval_unit: minutes

  # 1. 无依赖的基础任务
  fetch_history:
    endpoint: /fetch/bili-history
    method: GET
    name: 获取B站历史记录
    params: { }
    requires: [ ]
    schedule:
      time: 00:00
      type: daily

  # 2. 依赖 fetch_history
  import_data:
    endpoint: /importSqlite/import_data_sqlite
    method: POST
    name: 导入数据到数据库
    requires:
      - fetch_history
    schedule:
      type: chain

  # 3. 依赖 import_data
  analyze_data:
    endpoint: /analysis/analyze
    method: POST
    name: 分析历史数据
    requires:
      - import_data
    schedule:
      type: chain

  # 4. 依赖 analyze_data
  generate_heatmap:
    endpoint: /heatmap/generate_heatmap
    method: POST
    name: 生成观看热力图
    requires:
      - analyze_data
    schedule:
      type: chain

  # 5. 依赖 generate_heatmap
  send_daily_report:
    endpoint: /log/send-email
    method: POST
    name: 发送每日报告
    params:
      content: null
      mode: simple
      subject: B站历史记录日报 - {current_time}
    requires:
      - generate_heatmap
    schedule:
      type: chain
