05/31 Phase 2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Cron script: fetch daily USD/VND exchange rate.
|
||||
Run by systemd timer pfm-fxrate.timer at 8AM daily.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from app import create_app
|
||||
from app.services.fx_service import get_today_rate
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == '__main__':
|
||||
with app.app_context():
|
||||
result = get_today_rate()
|
||||
if result:
|
||||
status = '(stale)' if result.get('is_stale') else ''
|
||||
print(f"[fx_rate] 1 USD = {result['rate']:,.0f} VND "
|
||||
f"[{result['source']}] {result['date']} {status}")
|
||||
else:
|
||||
print("[fx_rate] Failed to fetch rate.")
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user