Speedup the signoff report by short circuiting when the first task not on today is found

This commit is contained in:
Campbell Alden 2024-12-23 18:09:10 +09:00
parent c6942468b2
commit 154793ccbe
2 changed files with 28 additions and 26 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "day-reporter"
version = "1.4.0"
version = "1.4.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -12,31 +12,33 @@ to.setHours(23);
to.setMinutes(59);
to.setSeconds(59);
logbook.filter(task => {
return task.completionDate() >= from && task.completionDate() < to;
}).forEach(todo => {
var proj = todo.project();
var tags = [];
if (proj) {
tags.push(...proj.tagNames().split(', '));
for (const todo of logbook) {
if(todo.completionDate() >= from && todo.completionDate() < to) {
var proj = todo.project();
var tags = [];
if (proj) {
tags.push(...proj.tagNames().split(', '));
}
var area = todo.area() || proj && proj.area();
objs.push({
id: todo.id(),
title: todo.name(),
notes: todo.notes() || null,
status: todo.status(),
completion_date: todo.completionDate(),
project: proj && {
id: proj.id(),
title: proj.name(),
status: proj.status(),
notes: proj.notes(),
tags: proj.tagNames().split(', '),
},
area: area && { id: area.id(), title: area.name() },
tags: [...tags, ...todo.tagNames().split(', ')].filter(t => t),
});
} else {
break;
}
var area = todo.area() || proj && proj.area();
objs.push({
id: todo.id(),
title: todo.name(),
notes: todo.notes() || null,
status: todo.status(),
completion_date: todo.completionDate(),
project: proj && {
id: proj.id(),
title: proj.name(),
status: proj.status(),
notes: proj.notes(),
tags: proj.tagNames().split(', '),
},
area: area && { id: area.id(), title: area.name() },
tags: [...tags, ...todo.tagNames().split(', ')].filter(t => t),
});
});
}
return JSON.stringify(objs, undefined, 2);