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())