dsh-workbench-tasks 5.5.4 → 5.9.0
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/lib/client.js +3588 -4346
- package/lib/index.js +18 -4
- package/lib/infra/backup.js +6 -15
- package/lib/infra/config.js +130 -418
- package/lib/infra/sync.js +1 -2
- package/lib/stats/activity-calendar.js +19 -9
- package/lib/stats/difficulty-bins.js +8 -5
- package/lib/stats/node-scope.js +151 -0
- package/lib/stats/stats-today.js +8 -4
- package/lib/stats/stats.js +81 -56
- package/lib/stats/timeline-stats.js +29 -9
- package/lib/task/write/task-bulk.js +3 -1
- package/lib/task/write/task-claim.js +8 -4
- package/lib/task/write/task-create.js +1 -1
- package/lib/task/write/task-update.js +3 -3
- package/lib/tasks.js +3 -2
- package/lib/timeline/timeline-sync.js +2 -0
- package/package.json +6 -12
|
@@ -100,7 +100,9 @@ export function applyPatchRow(db, cur, patch, ts) {
|
|
|
100
100
|
if (next.status === "2" && (next.difficulty === null || next.difficulty === undefined)) next.difficulty = 0;
|
|
101
101
|
if (next.status !== "0" && next.status !== "4") next.priority = 0;
|
|
102
102
|
else if (!next.priority) next.priority = 1;
|
|
103
|
-
|
|
103
|
+
// 进入终态只清「仍持锁」的凭据:claimed_at 与 owner 是历史事实(真实接取时间、办结人),
|
|
104
|
+
// 清掉会让「最近接取」与审计回溯永远查不到,5.8.0 起保留。
|
|
105
|
+
if (next.status === "1" || next.status === "2") next.claim_token = null;
|
|
104
106
|
if (next.status === "1" && !next.shutdown_date) next.shutdown_date = todayStr();
|
|
105
107
|
checkRequiredDates(next);
|
|
106
108
|
next.updated_at = ts;
|
|
@@ -217,11 +217,15 @@ export function assertClaimToken(db, id, token) {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
/**
|
|
221
|
-
|
|
220
|
+
/**
|
|
221
|
+
* 进入终态(关闭/完成/重启)时清空接取锁凭据。
|
|
222
|
+
*
|
|
223
|
+
* 5.8.0 起只清 claim_token:它是「仍持锁」的凭据,留在终态会被误读成任务还在办。
|
|
224
|
+
* claimed_at 与 owner 是历史事实(真实接取时间、办结人),保留才能让「最近接取」
|
|
225
|
+
* 与审计回溯查到已完成/已关闭任务的接取记录——这正是用户否掉「终态清空」的原因。
|
|
226
|
+
*/
|
|
227
|
+
export function clearClaimToken(row) {
|
|
222
228
|
const next = Object.assign({}, row);
|
|
223
|
-
next.owner = null;
|
|
224
|
-
next.claimed_at = null;
|
|
225
229
|
next.claim_token = null;
|
|
226
230
|
return next;
|
|
227
231
|
}
|
|
@@ -141,7 +141,7 @@ export function createTask(db, args, origin, api, opts) {
|
|
|
141
141
|
).all(restartKey);
|
|
142
142
|
const shutdownTs = now();
|
|
143
143
|
for (const old of active) {
|
|
144
|
-
const next = Object.assign({}, old, { status: "1", priority: 0, shutdown_date: todayStr(),
|
|
144
|
+
const next = Object.assign({}, old, { status: "1", priority: 0, shutdown_date: todayStr(), claim_token: null, updated_at: shutdownTs, rev: Number(old.rev) + 1 });
|
|
145
145
|
saveTaskRow(db, next);
|
|
146
146
|
writeChange(db, next, "update", origin, api, shutdownTs);
|
|
147
147
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { tagMissingNotices, withNotices, STATUSES, STATUS_NAMES, asCode, putTypeCode, clampDifficulty, dateArg, getTask, requireTable, saveTaskRow, outOne, writeChange, checkRequiredDates, resolveTagPatch } from "../model/task-model.js";
|
|
15
15
|
import { taskTransaction } from './task-transaction.js';
|
|
16
16
|
import { setTaskWorkspaces, attachWorkspaces } from '../../workspace/workspace-store.js';
|
|
17
|
-
import { assertClaimToken,
|
|
17
|
+
import { assertClaimToken, clearClaimToken, claimError } from './task-claim.js';
|
|
18
18
|
import { ownershipFields } from '../model/task-ownership-path.js';
|
|
19
19
|
export function updateTask(db, args, origin, api, opts) {
|
|
20
20
|
if (!opts?.skipTx) return taskTransaction(db, api, buffered => updateTask(db,args,origin,buffered,{skipTx:true}));
|
|
@@ -80,8 +80,8 @@ export function updateTask(db, args, origin, api, opts) {
|
|
|
80
80
|
// 优先级不变量兜底:非开启/非已接取状态一律 P0;开启类不允许 P0(历史数据回落到 P1)。
|
|
81
81
|
if (next.status !== "0" && next.status !== "4") next.priority = 0;
|
|
82
82
|
else if (!next.priority) next.priority = 1;
|
|
83
|
-
//
|
|
84
|
-
if (next.status === "1" || next.status === "2") Object.assign(next,
|
|
83
|
+
// 进入终态只清接取锁凭据(claim_token);claimed_at 与 owner 作为历史事实保留。
|
|
84
|
+
if (next.status === "1" || next.status === "2") Object.assign(next, clearClaimToken(next));
|
|
85
85
|
if (next.status === "1" && next.shutdown_date === null) next.shutdown_date = todayStr();
|
|
86
86
|
checkRequiredDates(next);
|
|
87
87
|
next.updated_at = ts;
|
package/lib/tasks.js
CHANGED
|
@@ -411,10 +411,11 @@ export function registerTaskActions(api) {
|
|
|
411
411
|
});
|
|
412
412
|
|
|
413
413
|
action("tasks.statsReport", {
|
|
414
|
-
description: "任务统计报表:总量/状态/标签/优先级/难度、趋势、逾期账龄、近期发布/完成/关闭清单(lists.recentPublish 不限状态,按发布日期倒序;lists.recentDone / lists.recentShutdown 分别按完成/关闭日期倒序;lists.recentClaimed
|
|
414
|
+
description: "任务统计报表:总量/状态/标签/优先级/难度、趋势、逾期账龄、近期发布/完成/关闭清单(lists.recentPublish 不限状态,按发布日期倒序;lists.recentDone / lists.recentShutdown 分别按完成/关闭日期倒序;lists.recentClaimed 为最近接取清单,凡 claimed_at 有真实毫秒戳(>0)就列出、不再限制状态(5.8.0 起已完成/已关闭/已重启也保留接取时间),按接取时间倒序,日期为接取时间的本地日期,行内 owner 为当前执有人(已接取)或办结人(终态;终态只清 claim_token,保留 claimed_at 与 owner 作为历史事实;5.6.x 及更早被清空的历史行由维护脚本按发布日期回填并在 audit_log 留痕,那些行的日期等同发布日);lists.overdue 为逾期清单)、任务表 / 任务组 / 工作区排行(rankings.workspaces 为存量口径,同一任务按存活关联在每个工作区各计一次,各行合计会大于 totals.total;rankings.noWorkspace 是未关联任何存活工作区的任务数,属正常状态,与 tasks.list 的 noWorkspace 同口径);breakdowns.difficulty 受 dimension 控制(all=当前存量;done/publish/claimed/shutdown 与 tasks.activityCalendar 同口径、按区间统计,回显在 breakdowns.difficultyDimension);eventTrend 为「事件趋势」:与 tasks.activityCalendar 完全同口径的五条序列(publish/done/shutdown/claimed 四类事件 + target 计划数),按页首区间的日/周/月桶聚合为 [{bucket,publish,done,shutdown,claimed,target}],桶数与 trend 一致,eventTrendTypes 给出序列顺序;target 是计划口径(target_date,只排除已删除任务),不计入 trend 的 created/done/due,也不改 totals.total;nodeId 是作用于整页的「任务节点」全局范围(选任务组=其下全部任务表、选任务表=该表、根节点或省略=全库),totals / 状态构成 / 优先级 / 难度 / trend / eventTrend / 逾期账龄与逾期清单 / 三个排行 / recent 四清单 / today 均只统计该子树内的任务,事件范围起点与「全部」时间范围也按子树算;节点不存在或已删除时回退根节点并在 scope.fallback=true 与 warnings 里标记 node_scope_fallback,空子树返回全 0 并在 warnings 标记 node_scope_empty,绝不静默按全库统计;返回值 scope 回显生效节点 {nodeId,nodeTitle,nodePath,isRoot,tableCount,requested,fallback};另返回 today 对象:" + TODAY_STATS_DESCRIPTION,
|
|
415
415
|
input: {
|
|
416
416
|
type: "object",
|
|
417
417
|
properties: {
|
|
418
|
+
nodeId: { type: ["string", "number"], description: "任务节点 id(全局范围):选任务组=其下全部任务表、选任务表=该表、根节点 1 或省略=全库;与 range/from/to 叠加生效。节点不存在或已删除时回退根节点并在 scope.fallback 与 warnings 标记" },
|
|
418
419
|
range: { type: "string", enum: ["7d", "30d", "90d", "365d", "all"], description: "默认 30d" },
|
|
419
420
|
from: { type: "string", description: "YYYY-MM-DD,与 to 同时提供" },
|
|
420
421
|
to: { type: "string", description: "YYYY-MM-DD,默认今天" },
|
|
@@ -426,7 +427,7 @@ export function registerTaskActions(api) {
|
|
|
426
427
|
recentClaimedLimit: { type: "number", description: "「最近接取」清单条数,1–50,默认 10" },
|
|
427
428
|
},
|
|
428
429
|
},
|
|
429
|
-
examples: [{ range: "30d", top: 10 }, { from: "2026-10-01", to: "2026-10-31" }, { range: "30d", dimension: "done" }],
|
|
430
|
+
examples: [{ range: "30d", top: 10 }, { from: "2026-10-01", to: "2026-10-31" }, { range: "30d", dimension: "done", nodeId: "1" }],
|
|
430
431
|
execute: function (args) { return statsReport(db, args || {}, api); },
|
|
431
432
|
render: renderStats,
|
|
432
433
|
});
|
|
@@ -14,6 +14,8 @@ export function normalizeTimelineTask({db,row,local}) {
|
|
|
14
14
|
if (!hasTimelineKey && local) result.timeline_key = local.timeline_key;
|
|
15
15
|
// 旧客户端不认识接取列:incoming 缺这三列时保留本地值,绝不用 undefined 清空;
|
|
16
16
|
// 显式传 null 视为新值(例如对方已释放),交给整行覆盖逻辑。
|
|
17
|
+
// 5.8.0 起终态也保留 claimed_at/owner(只清 claim_token),所以对端发来的终态行
|
|
18
|
+
// 若带真实接取时间与办结人,这里按普通字段整行保留即可,不会被本地规则抹掉。
|
|
17
19
|
for (const column of ["owner", "claimed_at", "claim_token"]) {
|
|
18
20
|
if (!Object.hasOwn(row, column) && local) result[column] = local[column];
|
|
19
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-tasks",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0",
|
|
4
4
|
"description": "个人工作台任务插件:任务树、优先级、截止日、时间线与重启",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"addon": {
|
|
17
17
|
"id": "wb-addon-tasks",
|
|
18
18
|
"title": "任务",
|
|
19
|
-
"description": "任务树 +
|
|
20
|
-
"version": "5.
|
|
19
|
+
"description": "任务树 + 统计/记录/时间线/工作区四个视图:紧急/已关闭/已开启/已完成/总览,可按标签筛选,附统计报表;配置项由宿主统一配置中心渲染",
|
|
20
|
+
"version": "5.9.0",
|
|
21
21
|
"minShell": "0.15.0",
|
|
22
22
|
"tables": [
|
|
23
23
|
"task",
|
|
@@ -31,9 +31,7 @@
|
|
|
31
31
|
"stats",
|
|
32
32
|
"tasks",
|
|
33
33
|
"timeline",
|
|
34
|
-
"workspace"
|
|
35
|
-
"config",
|
|
36
|
-
"actions"
|
|
34
|
+
"workspace"
|
|
37
35
|
],
|
|
38
36
|
"toolActions": [
|
|
39
37
|
"tasks.list",
|
|
@@ -82,11 +80,7 @@
|
|
|
82
80
|
"taskNodes.delete",
|
|
83
81
|
"tasks.history",
|
|
84
82
|
"tasks.changelog",
|
|
85
|
-
"tasks.export"
|
|
86
|
-
"tasks.configGet",
|
|
87
|
-
"tasks.configSet",
|
|
88
|
-
"tasks.configReset",
|
|
89
|
-
"tasks.configOptions"
|
|
83
|
+
"tasks.export"
|
|
90
84
|
],
|
|
91
85
|
"client": "lib/client.js"
|
|
92
86
|
}
|
|
@@ -97,7 +91,7 @@
|
|
|
97
91
|
"./package.json": "./package.json"
|
|
98
92
|
},
|
|
99
93
|
"dependencies": {
|
|
100
|
-
"dsh-workbench-host": "^0.
|
|
94
|
+
"dsh-workbench-host": "^0.19.0"
|
|
101
95
|
},
|
|
102
96
|
"dsh": {
|
|
103
97
|
"bundle": {
|