fix(migration): todoist pagination now avoids too many loops

This commit is contained in:
kolaente 2023-01-24 22:27:49 +01:00
parent 0cd9cd324e
commit 682123a9c9
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
2 changed files with 6 additions and 1 deletions

View File

@ -226,6 +226,9 @@ func insertFromStructure(s *xorm.Session, str []*models.NamespaceWithListsAndTas
// If not, create one and save it for later
var lb *models.Label
var exists bool
if label == nil {
continue
}
lb, exists = labels[label.Title+label.HexColor]
if !exists {
err = label.Create(s, user)

View File

@ -35,6 +35,8 @@ import (
"code.vikunja.io/api/pkg/utils"
)
const paginationLimit = 200
// Migration is the todoist migration struct
type Migration struct {
Code string `json:"code"`
@ -554,7 +556,7 @@ func (m *Migration) Migrate(u *user.User) (err error) {
doneItems := make(map[string]*doneItem)
for {
resp, err = migration.DoPostWithHeaders("https://api.todoist.com/sync/v9/completed/get_all?limit=200&offset="+strconv.Itoa(offset), form, bearerHeader)
resp, err = migration.DoPostWithHeaders("https://api.todoist.com/sync/v9/completed/get_all?limit="+strconv.Itoa(paginationLimit)+"&offset="+strconv.Itoa(offset*paginationLimit), form, bearerHeader)
if err != nil {
return
}