refactor: add separation of concerns in fetcher and platform

This commit is contained in:
Alexander Navarro 2024-11-30 18:14:04 -03:00
parent 96af51ee68
commit 4094f71a7d
5 changed files with 227 additions and 145 deletions

View file

@ -89,16 +89,12 @@ func (collection *Collection) IsDefault() bool {
type NodeFetcher = func(metadata []byte, pagination Pagination) ([]*Node, Pagination, error)
func (collection *Collection) FetchNodes(fetcher NodeFetcher, start_pagination Pagination) error {
nodes, pagination, err := fetcher(collection.GetMetadata(), start_pagination)
nodes, _, err := fetcher(collection.GetMetadata(), start_pagination)
if err != nil {
return err
}
collection.childs = slices.Concat(collection.childs, nodes)
if pagination.HasMore {
return collection.FetchNodes(fetcher, pagination)
}
err = BulkCreateNode(collection._conn, collection.childs)
if err != nil {
return err