simpler update

This commit is contained in:
Erik Winter 2024-12-29 10:18:11 +01:00
parent e2ce33899f
commit c8e5058445
1 changed files with 7 additions and 11 deletions

View File

@ -1,12 +1,14 @@
package command package command
import ( import (
"errors"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"go-mod.ewintr.nl/planner/item" "go-mod.ewintr.nl/planner/item"
"go-mod.ewintr.nl/planner/plan/storage"
) )
type UpdateArgs struct { type UpdateArgs struct {
@ -84,18 +86,12 @@ type Update struct {
} }
func (u *Update) Do(deps Dependencies) ([][]string, error) { func (u *Update) Do(deps Dependencies) ([][]string, error) {
var id string id, err := deps.LocalIDRepo.FindOne(u.args.LocalID)
idMap, err := deps.LocalIDRepo.FindAll() switch {
if err != nil { case errors.Is(err, storage.ErrNotFound):
return nil, fmt.Errorf("could not get local ids: %v", err)
}
for tid, lid := range idMap {
if u.args.LocalID == lid {
id = tid
}
}
if id == "" {
return nil, fmt.Errorf("could not find local id") return nil, fmt.Errorf("could not find local id")
case err != nil:
return nil, err
} }
tsk, err := deps.TaskRepo.Find(id) tsk, err := deps.TaskRepo.Find(id)