05/31 Phase 2

This commit is contained in:
2026-05-31 11:17:53 -04:00
parent 1c34dcbd28
commit 9f2a0acc38
18 changed files with 1817 additions and 391 deletions
+25
View File
@@ -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)