Files
8b682aa6f6 fix(coinbaseprime): avoid refetching payments on every account fetch cycle (#707)
* fix(coinbaseprime): avoid refetching payments on every account fetch

TASK_FETCH_PAYMENTS was a child of TASK_FETCH_ACCOUNTS, so payments
were re-fetched from scratch on every account sync cycle. Moving it
to a top-level sibling task makes it run independently on its own
schedule instead of being triggered by every account fetch.

Backport of fix from PR #657 (fd62842).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(coinbaseprime): fix cursor reset causing full refetch on every cycle

Without advanceCursor, when Coinbase returns an empty next_cursor at
end-of-pagination the state was reset to an empty cursor, causing the
next run to refetch all transactions from the beginning.

- Extract paymentsState into shared incrementalState in state.go
- Introduce advanceCursor: keep the previous cursor when next_cursor is
  empty so the pagination marker is never wiped

Backport of fix from PR #657 (fd62842).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test(coinbaseprime): add unit tests for advanceCursor

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
2026-05-04 10:15:55 +02:00

28 lines
655 B
Go

package coinbaseprime
import "github.com/formancehq/payments/internal/models"
func workflow() models.ConnectorTasksTree {
return []models.ConnectorTaskTree{
{
TaskType: models.TASK_FETCH_ACCOUNTS,
Name: "fetch_accounts",
Periodically: true,
NextTasks: []models.ConnectorTaskTree{
{
TaskType: models.TASK_FETCH_BALANCES,
Name: "fetch_balances",
Periodically: true,
NextTasks: []models.ConnectorTaskTree{},
},
},
},
{
TaskType: models.TASK_FETCH_PAYMENTS,
Name: "fetch_payments",
Periodically: true,
NextTasks: []models.ConnectorTaskTree{},
},
}
}