diff --git a/Readme.md b/Readme.md index a97f767..548228f 100644 --- a/Readme.md +++ b/Readme.md @@ -10,7 +10,7 @@ Add a Label with the text "Daily" and a colome with the Text "ToDo", it will mov Remove cards from the "Done" list which are older than 7 days ## move-backlog-card-with-date -Move all cards in the Backlog where the due date is in the past to the "ToDo" list and remove the due date +Move all cards in the Backlog where the due date is in the past to the "ToDo" list and remove the due date. Move the cards with due date in the Back log list to the end of the list. Add a text comment. ## unassign-cards Assign all card with have no assign user to the user how run the script diff --git a/move-backlog-card-with-date.go b/move-backlog-card-with-date.go index 369ee4b..540613b 100644 --- a/move-backlog-card-with-date.go +++ b/move-backlog-card-with-date.go @@ -50,11 +50,21 @@ func moveBacklogCardWithDate(cCtx *cli.Context) error { return fmt.Errorf("cant get card for Backlog list list: %w", err) } + var cardsToMoveToTheEndOfTheList []*trello.Card + for _, card := range cards { log.Debug().Str("name", card.Name).Msg("Found card") if card.Due == nil { + for _, cardToMove := range cardsToMoveToTheEndOfTheList { + err = cardToMove.MoveToBottomOfList() + if err != nil { + return fmt.Errorf("cant move card to end: %w", err) + } + } + cardsToMoveToTheEndOfTheList = []*trello.Card{} continue } + cardsToMoveToTheEndOfTheList = append(cardsToMoveToTheEndOfTheList, card) if card.Due.Before(time.Now()) { err = card.MoveToList(todoList.ID) if err != nil {