Files
site/WESP_REL/scripts/cleanup_legacy_profiles.py
T
2026-07-17 12:57:18 +03:00

39 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Удаление legacy и fp_* профилей стада."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent.parent
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from app import create_app # noqa: E402
from app.lab.commands.cleanup_legacy_profiles import cleanup_legacy_profiles # noqa: E402
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--apply", action="store_true", help="Execute deletion (default: dry-run)")
args = parser.parse_args()
app = create_app()
with app.app_context():
report = cleanup_legacy_profiles(dry_run=not args.apply)
print(f"dry_run={report.dry_run}")
print(f"profiles_to_delete ({len(report.profiles_to_delete)}):")
for key in report.profiles_to_delete:
print(f" - {key}")
print(f"recipe_ids_cleared ({len(report.recipe_ids_cleared)}):")
for rid in report.recipe_ids_cleared:
print(f" - {rid}")
print(f"norms_deleted={report.norms_deleted} profiles_deleted={report.profiles_deleted}")
return 0
if __name__ == "__main__":
raise SystemExit(main())