from __future__ import annotations import argparse from datetime import date from app.services.historical_sync import get_historical_sync_service from app.utils.serialization import to_plain parser = argparse.ArgumentParser(description="Import daily PV aggregates from InfluxDB into the local SQLite cache") parser.add_argument("--start-date", dest="start_date", help="Start date YYYY-MM-DD") parser.add_argument("--end-date", dest="end_date", help="End date YYYY-MM-DD") parser.add_argument("--chunk-days", dest="chunk_days", type=int, default=7, help="Number of days per chunk") parser.add_argument("--force", action="store_true", help="Overwrite days already stored in the cache") args = parser.parse_args() service = get_historical_sync_service() status = service.run_blocking( start_date=date.fromisoformat(args.start_date) if args.start_date else None, end_date=date.fromisoformat(args.end_date) if args.end_date else None, chunk_days=args.chunk_days, force=args.force, ) print(to_plain(status))