container: fetch: coinbase: fix/update pagination

- Don't break before advancing 'starting_after' cursor
  * Only save given year instead of breaking when not given year

- The 'next_starting_after' cursor now exists within 'info' object
This commit is contained in:
2025-01-07 17:35:39 -08:00
parent 27d1b44adb
commit 80039297a3

View File

@@ -2,7 +2,7 @@
// docker-finance | modern accounting for the power-user
//
// Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -174,17 +174,15 @@ namespace docker_finance\exchanges\internal\exchanges\coinbase
// Format: 1970-01-01T12:34:56Z
$created_at = $info['created_at'];
$at_year = explode('-', $created_at)[0];
if ($at_year != $given_year) {
break 2;
if ($at_year == $given_year) {
$stack[$id][] = $txs[$i];
}
$stack[$id][] = $txs[$i];
}
// Paginate (if needed)
$last = $txs[array_key_last($txs)];
if (array_key_exists('next_starting_after', $last)) {
$account['starting_after'] = $last['next_starting_after'];
if (array_key_exists('next_starting_after', $last['info'])) {
$account['starting_after'] = $last['info']['next_starting_after'];
} else {
break;
}