Fix for issue 44, runs always starting at 0 pomodoros

This commit is contained in:
WN 2022-01-05 17:36:12 +01:00
parent 90b853492d
commit c1416ef9dc
3 changed files with 8 additions and 5 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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
}