From 154793ccbed13ac20c0941746451c42718dfaff8 Mon Sep 17 00:00:00 2001 From: Campbell Alden Date: Mon, 23 Dec 2024 18:09:10 +0900 Subject: [PATCH] Speedup the signoff report by short circuiting when the first task not on today is found --- Cargo.toml | 2 +- src/things/logbook.js | 52 ++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 44e805d..c5c19b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/src/things/logbook.js b/src/things/logbook.js index dd3439e..326abac 100644 --- a/src/things/logbook.js +++ b/src/things/logbook.js @@ -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);