#!/usr/bin/env python3
"""手动执行 S/A 需求视频点位拓展任务。

用法:
    python jobs/expand_demand_from_video_points.py                  # 最新/当天 biz_dt
    python jobs/expand_demand_from_video_points.py 20260721          # 指定业务日
    python jobs/expand_demand_from_video_points.py 20260721 5        # 指定业务日 + 5 并发
    python jobs/expand_demand_from_video_points.py 20260721 --force   # 忽略已完成记录重跑
"""
from __future__ import annotations

import logging
import sys

from supply_infra.scheduler.jobs.expand_demand_from_video_points import (
    expand_demand_from_video_points,
)

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)


def main(
    biz_dt: str | None = None,
    workers_arg: str | None = None,
    *,
    skip_finished: bool = True,
) -> dict:
    workers = int(workers_arg) if workers_arg else 5
    result = expand_demand_from_video_points(
        biz_dt,
        skip_finished=skip_finished,
        workers=workers,
    )
    print(result)
    return result


if __name__ == "__main__":
    args = sys.argv[1:]
    biz_dt_arg = args[0] if args and not args[0].startswith("-") else None
    workers_arg = None
    if biz_dt_arg and len(args) > 1 and not args[1].startswith("-"):
        workers_arg = args[1]
    skip_finished = "--force" not in args
    main(biz_dt_arg, workers_arg, skip_finished=skip_finished)
