task: add history and spot probes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
06c7091bb3
commit
85cc7961b8
1 file changed
+30
-2
@@ -221,6 +221,34 @@ def cmd_recheck() -> None:
|
|||||||
f"{same_id_posted} posted under the same id, {still_pending} still pending, {vanished} id gone")
|
f"{same_id_posted} posted under the same id, {still_pending} still pending, {vanished} id gone")
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_history() -> None:
|
||||||
|
"""Pull 40-day slices back 200 days: is there a per-response cap, and how deep is history? (5 requests)"""
|
||||||
|
url = access_url()
|
||||||
|
now = int(time.time())
|
||||||
|
print("slice (days ago) per account: count, posted range")
|
||||||
|
for lo in range(0, 200, 40):
|
||||||
|
resp = get_accounts(url, **{"start-date": str(now - (lo + 40) * DAY), "end-date": str(now - lo * DAY)})
|
||||||
|
conns = {c.get("conn_id"): c for c in resp.get("connections") or []}
|
||||||
|
for a in resp.get("accounts", []):
|
||||||
|
ps = [t["posted"] for t in a.get("transactions") or [] if t.get("posted")]
|
||||||
|
print(f" {lo:3d}..{lo + 40:3d} {org_of(a, conns)!r}: {len(ps):3d} {day(min(ps, default=None))} .. {day(max(ps, default=None))}")
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_spot() -> None:
|
||||||
|
"""LOCAL ONLY, do not paste: last 10 days, raw dates + amounts to compare with the bank's website. (1 request)"""
|
||||||
|
url = access_url()
|
||||||
|
now = int(time.time())
|
||||||
|
resp = get_accounts(url, **{"start-date": str(now - 10 * DAY)})
|
||||||
|
conns = {c.get("conn_id"): c for c in resp.get("connections") or []}
|
||||||
|
fmt = lambda ts: datetime.fromtimestamp(ts, UTC).strftime("%Y-%m-%d %H:%M:%SZ") if ts else "-" # noqa: E731
|
||||||
|
print("!! Contains amounts and descriptions. Compare with the bank site; do NOT paste this output.\n")
|
||||||
|
for a in resp.get("accounts", []):
|
||||||
|
print(f"{org_of(a, conns)} {(a.get('name') or '')[:3]}…")
|
||||||
|
print(f" {'posted':21} {'transacted_at':21} {'amount':>10} description")
|
||||||
|
for t in sorted(a.get("transactions") or [], key=lambda t: t.get("posted") or 0, reverse=True)[:15]:
|
||||||
|
print(f" {fmt(t.get('posted')):21} {fmt(t.get('transacted_at')):21} {t.get('amount', ''):>10} {(t.get('description') or '')[:30]}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
{"claim": cmd_claim, "run": cmd_run, "recheck": cmd_recheck}.get(
|
{"claim": cmd_claim, "run": cmd_run, "recheck": cmd_recheck, "history": cmd_history, "spot": cmd_spot}.get(
|
||||||
sys.argv[1] if len(sys.argv) > 1 else "", lambda: die("usage: probe.py claim|run|recheck"))()
|
sys.argv[1] if len(sys.argv) > 1 else "", lambda: die("usage: probe.py claim|run|recheck|history|spot"))()
|
||||||
Reference in new issue
Block a user