2026-05-18 09:10:09 +00:00
|
|
|
from IngestionService.ingester import Ingester
|
2026-05-31 23:18:27 +00:00
|
|
|
from FireflySync.firefly_sync import FireflySync
|
2026-05-18 22:47:46 +00:00
|
|
|
from config import load_env
|
2026-05-18 23:02:39 +00:00
|
|
|
import os
|
2026-05-18 09:10:09 +00:00
|
|
|
|
2026-05-18 22:47:46 +00:00
|
|
|
load_env("IngestionService")
|
2026-05-18 09:10:09 +00:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
ingester = Ingester()
|
2026-05-18 22:47:46 +00:00
|
|
|
ingester.test_db_connection()
|
|
|
|
|
|
2026-05-18 23:02:39 +00:00
|
|
|
run_akahu = os.getenv("RUN_AKAHU", "true").strip().lower() in {"1", "true", "yes"}
|
|
|
|
|
run_emoney = os.getenv("RUN_EMONEY", "true").strip().lower() in {"1", "true", "yes"}
|
|
|
|
|
run_normalize = os.getenv("RUN_NORMALIZE", "true").strip().lower() in {"1", "true", "yes"}
|
2026-05-31 23:18:27 +00:00
|
|
|
run_firefly = os.getenv("RUN_FIREFLY", "false").strip().lower() in {"1", "true", "yes"}
|
2026-05-18 22:47:46 +00:00
|
|
|
|
2026-05-18 23:02:39 +00:00
|
|
|
if run_akahu:
|
|
|
|
|
akahu_accounts = ingester.fetch_akahu_snapshot_data()
|
|
|
|
|
#print("Akahu accounts fetched:", len(akahu_accounts.get("items", [])))
|
|
|
|
|
ingester.write_akahu_snapshot_data(akahu_accounts)
|
2026-05-18 22:47:46 +00:00
|
|
|
|
2026-05-18 23:02:39 +00:00
|
|
|
#backfill_start = "2026-01-01"
|
|
|
|
|
#backfill_end = "2026-12-31"
|
|
|
|
|
#akahu_backfill = ingester.backfill_akahu_transactions(backfill_start, backfill_end)
|
|
|
|
|
#print("Akahu backfill transactions:", len(akahu_backfill.get("items", [])))
|
2026-05-18 22:47:46 +00:00
|
|
|
|
2026-05-18 23:02:39 +00:00
|
|
|
if run_emoney:
|
|
|
|
|
emoney_data = ingester.fetch_emoney_data()
|
|
|
|
|
emoney_snapshot = emoney_data.get("snapshot") or {"accounts": []}
|
|
|
|
|
emoney_transactions = emoney_data.get("transactions") or []
|
|
|
|
|
#print("Emoney snapshot accounts:", len(emoney_snapshot.get("accounts", [])))
|
|
|
|
|
ingester.write_emoney_snapshot_data(emoney_snapshot)
|
|
|
|
|
#print("Emoney transactions:", len(emoney_transactions))
|
|
|
|
|
ingester.write_emoney_transaction_data(emoney_transactions)
|
|
|
|
|
|
|
|
|
|
if run_normalize:
|
|
|
|
|
ingester.normalize_pending_data()
|
2026-05-31 23:18:27 +00:00
|
|
|
|
|
|
|
|
if run_firefly:
|
|
|
|
|
firefly = FireflySync(ingester.dbconnection)
|
|
|
|
|
firefly.sync()
|