apply updates in commands and done test

This commit is contained in:
Erik Winter 2021-09-07 06:50:30 +02:00
parent 3d1f5361c8
commit 5147625901
7 changed files with 25 additions and 6 deletions

View File

@ -36,6 +36,7 @@ func NewFolder(conf *configuration.Configuration, cmdArgs []string) (*Folder, er
reqs := process.ListReqs{ reqs := process.ListReqs{
Folder: folder, Folder: folder,
ApplyUpdates: true,
} }
lister := process.NewList(local, reqs) lister := process.NewList(local, reqs)

View File

@ -23,6 +23,7 @@ func NewProject(conf *configuration.Configuration, cmdArgs []string) (*Project,
} }
reqs := process.ListReqs{ reqs := process.ListReqs{
Project: strings.ToLower(cmdArgs[0]), Project: strings.ToLower(cmdArgs[0]),
ApplyUpdates: true,
} }
lister := process.NewList(local, reqs) lister := process.NewList(local, reqs)

View File

@ -21,6 +21,7 @@ func NewToday(conf *configuration.Configuration) (*Today, error) {
reqs := process.ListReqs{ reqs := process.ListReqs{
Due: task.Today, Due: task.Today,
IncludeBefore: true, IncludeBefore: true,
ApplyUpdates: true,
} }
lister := process.NewList(local, reqs) lister := process.NewList(local, reqs)

View File

@ -21,6 +21,7 @@ func NewTomorrow(conf *configuration.Configuration) (*Tomorrow, error) {
reqs := process.ListReqs{ reqs := process.ListReqs{
Due: task.Today.Add(1), Due: task.Today.Add(1),
ApplyUpdates: true,
} }
lister := process.NewList(local, reqs) lister := process.NewList(local, reqs)

View File

@ -21,6 +21,7 @@ func NewWeek(conf *configuration.Configuration) (*Week, error) {
reqs := process.ListReqs{ reqs := process.ListReqs{
Due: task.Today.Add(7), Due: task.Today.Add(7),
IncludeBefore: true, IncludeBefore: true,
ApplyUpdates: true,
} }
return &Week{ return &Week{
lister: process.NewList(local, reqs), lister: process.NewList(local, reqs),

View File

@ -67,6 +67,13 @@ func (l *List) Process() (*ListResult, error) {
for i := range potentialTasks { for i := range potentialTasks {
potentialTasks[i].ApplyUpdate() potentialTasks[i].ApplyUpdate()
} }
var undoneTasks []*task.LocalTask
for _, pt := range potentialTasks {
if !pt.Done {
undoneTasks = append(undoneTasks, pt)
}
}
potentialTasks = undoneTasks
} }
// folder // folder

View File

@ -114,13 +114,20 @@ func TestListProcess(t *testing.T) {
t.Run("applyupdates", func(t *testing.T) { t.Run("applyupdates", func(t *testing.T) {
mem := storage.NewMemory() mem := storage.NewMemory()
test.OK(t, mem.SetTasks([]*task.Task{task2, task4})) test.OK(t, mem.SetTasks([]*task.Task{task2, task3, task4}))
lu := &task.LocalUpdate{ lu3 := &task.LocalUpdate{
ForVersion: task3.Version,
Fields: []string{task.FIELD_PROJECT, task.FIELD_DONE},
Project: "project4",
Done: true,
}
test.OK(t, mem.SetLocalUpdate(task3.Id, lu3))
lu4 := &task.LocalUpdate{
ForVersion: task4.Version, ForVersion: task4.Version,
Fields: []string{task.FIELD_PROJECT}, Fields: []string{task.FIELD_PROJECT},
Project: "project4", Project: "project4",
} }
test.OK(t, mem.SetLocalUpdate(task4.Id, lu)) test.OK(t, mem.SetLocalUpdate(task4.Id, lu4))
lr := process.ListReqs{ lr := process.ListReqs{
Project: "project4", Project: "project4",