From c1416ef9dc3132b1e76b819c08cf05ad99a45277 Mon Sep 17 00:00:00 2001 From: WN Date: Wed, 5 Jan 2022 17:36:12 +0100 Subject: [PATCH] Fix for issue 44, runs always starting at 0 pomodoros --- pkg/cmd/cmd.go | 5 ----- pkg/internal/runner.go | 1 + pkg/internal/store.go | 7 +++++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 6256d79..9aaa5ae 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -142,11 +142,6 @@ func begin(config *pomo.Config) func(*cli.Cmd) { return err } task = read - err = db.DeletePomodoros(tx, *taskId) - if err != nil { - return err - } - task.Pomodoros = []*pomo.Pomodoro{} return nil })) runner, err := pomo.NewTaskRunner(task, config) diff --git a/pkg/internal/runner.go b/pkg/internal/runner.go index 3ce1276..af12800 100644 --- a/pkg/internal/runner.go +++ b/pkg/internal/runner.go @@ -42,6 +42,7 @@ func NewTaskRunner(task *Task, config *Config) (*TaskRunner, error) { return nil, err } tr := &TaskRunner{ + count: len(task.Pomodoros), taskID: task.ID, taskMessage: task.Message, nPomodoros: task.NPomodoros, diff --git a/pkg/internal/store.go b/pkg/internal/store.go index 76a0906..28d3993 100644 --- a/pkg/internal/store.go +++ b/pkg/internal/store.go @@ -123,6 +123,13 @@ func (s Store) ReadTask(tx *sql.Tx, taskID int) (*Task, error) { if tags != "" { task.Tags = strings.Split(tags, ",") } + pomodoros, err := s.ReadPomodoros(tx, task.ID) + if err != nil { + return nil, err + } + for _, pomodoro := range pomodoros { + task.Pomodoros = append(task.Pomodoros, pomodoro) + } return task, nil }