feat(workspace): 增加工作活动日报引擎
This commit is contained in:
69
apps/web/lib/work-activity.ts
Normal file
69
apps/web/lib/work-activity.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
export type WorkActivitySourceType = 'version_plan' | 'dev_task' | 'test_case' | 'bug' | 'manual';
|
||||
|
||||
export type WorkActivityCategory = 'delivery' | 'progress' | 'creation' | 'risk' | 'note';
|
||||
|
||||
export type WorkActivityAction =
|
||||
| 'version_plan_created'
|
||||
| 'version_plan_started'
|
||||
| 'version_plan_completed'
|
||||
| 'dev_task_created'
|
||||
| 'dev_task_started'
|
||||
| 'dev_task_self_testing'
|
||||
| 'dev_task_submitted'
|
||||
| 'dev_task_blocked'
|
||||
| 'dev_task_unblocked'
|
||||
| 'dev_task_transferred'
|
||||
| 'test_case_created'
|
||||
| 'test_case_started'
|
||||
| 'test_case_passed'
|
||||
| 'test_case_failed'
|
||||
| 'test_case_blocked'
|
||||
| 'bug_created'
|
||||
| 'bug_fixing'
|
||||
| 'bug_fixed'
|
||||
| 'bug_closed'
|
||||
| 'bug_blocked'
|
||||
| 'bug_transferred'
|
||||
| 'progress_note_added';
|
||||
|
||||
export interface WorkActivity {
|
||||
id: string;
|
||||
actorId: string;
|
||||
date: string;
|
||||
occurredAt: string;
|
||||
sourceType: WorkActivitySourceType;
|
||||
sourceId: string;
|
||||
action: WorkActivityAction;
|
||||
category: WorkActivityCategory;
|
||||
title: string;
|
||||
summary: string;
|
||||
metadata?: {
|
||||
fromStatus?: string;
|
||||
toStatus?: string;
|
||||
note?: string;
|
||||
blocker?: string;
|
||||
helperId?: string;
|
||||
delayRisk?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export type WorkActivityDraft = Omit<WorkActivity, 'id' | 'date' | 'occurredAt'> & {
|
||||
date?: string;
|
||||
occurredAt?: string;
|
||||
};
|
||||
|
||||
export const WORK_ACTIVITY_CATEGORY_LABEL: Record<WorkActivityCategory, string> = {
|
||||
delivery: '今日交付',
|
||||
progress: '今日推进',
|
||||
creation: '今日新增',
|
||||
risk: '风险/阻塞',
|
||||
note: '进展说明',
|
||||
};
|
||||
|
||||
export function mergeWorkActivities(remote: WorkActivity[] = [], local: WorkActivity[] = []): WorkActivity[] {
|
||||
const byId = new Map<string, WorkActivity>();
|
||||
for (const item of remote) byId.set(item.id, item);
|
||||
for (const item of local) byId.set(item.id, item);
|
||||
return Array.from(byId.values()).sort((a, b) => a.occurredAt.localeCompare(b.occurredAt));
|
||||
}
|
||||
Reference in New Issue
Block a user