Merge pull request #57 from labno/master

Fix for issue 44, runs always starting at 0 pomodoros
This commit is contained in:
Kevin Schoon 2022-01-16 12:04:01 -05:00 committed by GitHub
commit e603f282cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 return err
} }
task = read task = read
err = db.DeletePomodoros(tx, *taskId)
if err != nil {
return err
}
task.Pomodoros = []*pomo.Pomodoro{}
return nil return nil
})) }))
runner, err := pomo.NewTaskRunner(task, config) runner, err := pomo.NewTaskRunner(task, config)

View File

@ -42,6 +42,7 @@ func NewTaskRunner(task *Task, config *Config) (*TaskRunner, error) {
return nil, err return nil, err
} }
tr := &TaskRunner{ tr := &TaskRunner{
count: len(task.Pomodoros),
taskID: task.ID, taskID: task.ID,
taskMessage: task.Message, taskMessage: task.Message,
nPomodoros: task.NPomodoros, nPomodoros: task.NPomodoros,

View File

@ -123,6 +123,13 @@ func (s Store) ReadTask(tx *sql.Tx, taskID int) (*Task, error) {
if tags != "" { if tags != "" {
task.Tags = strings.Split(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 return task, nil
} }