@aicupa/plugin-balance 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/service.js +8 -4
package/package.json
CHANGED
package/service.js
CHANGED
|
@@ -30,6 +30,11 @@ module.exports = createPlugin((api) => {
|
|
|
30
30
|
|
|
31
31
|
function collectDoneTime(node) {
|
|
32
32
|
let total = 0;
|
|
33
|
+
|
|
34
|
+
const today = new Date();
|
|
35
|
+
today.setHours(0, 0, 0, 0);
|
|
36
|
+
const startOfDayTimestamp = today.getTime();
|
|
37
|
+
|
|
33
38
|
if (!node) return total;
|
|
34
39
|
const stack = [node];
|
|
35
40
|
while (stack.length) {
|
|
@@ -40,6 +45,8 @@ module.exports = createPlugin((api) => {
|
|
|
40
45
|
n.todo?.end &&
|
|
41
46
|
n.todo.end > n.todo.start
|
|
42
47
|
) {
|
|
48
|
+
if (n.todo.keep) continue;
|
|
49
|
+
if (n.todo.start < startOfDayTimestamp) continue;
|
|
43
50
|
total += n.todo.end - n.todo.start;
|
|
44
51
|
}
|
|
45
52
|
if (Array.isArray(n.children)) {
|
|
@@ -96,10 +103,7 @@ module.exports = createPlugin((api) => {
|
|
|
96
103
|
const currentNode = findNodeById(tree, currentNodeId);
|
|
97
104
|
const tempTime = collectDoneTime(tempNode);
|
|
98
105
|
const currentTime = collectDoneTime(currentNode);
|
|
99
|
-
const percent =
|
|
100
|
-
currentTime > 0
|
|
101
|
-
? Math.round((tempTime / (currentTime + tempTime)) * 100)
|
|
102
|
-
: 0;
|
|
106
|
+
const percent = Math.round((tempTime / (currentTime + tempTime)) * 100);
|
|
103
107
|
|
|
104
108
|
return {
|
|
105
109
|
ok: true,
|