Spaces:
Sleeping
Sleeping
File size: 1,572 Bytes
aa9892b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """radio/realtime ์บ์ ๋์ ์ ๋ฆฌ CLI โ dry-run ์ฐ์ , ์ญ์ ๋ --apply.
ํต์ฌ ๋ก์ง์ services/radio_cache_prune.py ๊ณต์ฉ(์ผ์ผ ํฌ๋ก ๊ณผ ๋์ผ). ์ด CLI๋ ์๋ ์คํ/๊ฒ์ฆ์ฉ.
โ ๏ธ ์์ฑ ์๋์ญ์ ์ฌ๊ณ ์ด๋ ฅ ์ค์ โ ๋ฐ๋์ dry-run ํ์ธ ํ --apply.
์คํ(Oracle ์ปจํ
์ด๋ ๋ด):
python scripts/prune_radio_cache.py # dry-run(์ง๊ณ)
python scripts/prune_radio_cache.py --apply # ์ค์ ์ญ์
python scripts/prune_radio_cache.py --ments-days 14 --realtime-days 3
"""
from __future__ import annotations
import argparse
import asyncio
import sys
sys.path.insert(0, "/app/backend")
async def main():
ap = argparse.ArgumentParser()
ap.add_argument("--ments-days", type=int, default=7)
ap.add_argument("--realtime-days", type=int, default=2)
ap.add_argument("--apply", action="store_true", help="์ค์ ์ญ์ (๊ธฐ๋ณธ dry-run)")
args = ap.parse_args()
from services import radio_cache_prune as rcp
stats = await rcp.prune(
ments_days=args.ments_days, realtime_days=args.realtime_days, apply=args.apply)
mb = stats["bytes"] / 1024 / 1024
print(f"์ญ์ ํ๋ณด: {stats['candidates']}๊ฐ / {mb:.1f} MB "
f"(radio/ments >{args.ments_days}์ผ + realtime >{args.realtime_days}์ผ, studio ์ ์ธ)")
if args.apply:
print(f"[apply] ์ญ์ {stats['deleted']} ยท ์คํจ {stats['failed']}")
else:
print("[dry-run] ์ญ์ ์ ํจ. ์ค์ ์ญ์ = --apply")
if __name__ == "__main__":
asyncio.run(main())
|