fix: address code review feedback
- Fix execution-sync calling wrong method (pushExecutionLog → syncExecutionStatus) - Fix task queue preserving original fields on update - Fix redundant duplicate check in broadcast-listener - Fix workflow secret check pattern - Add Notion DB schema note in connector docs Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
70f678506e
commit
afc1897ef7
|
|
@ -32,7 +32,7 @@ jobs:
|
||||||
|
|
||||||
# ── Step 3: 同步到 Notion ──
|
# ── Step 3: 同步到 Notion ──
|
||||||
- name: 同步执行状态到 Notion
|
- name: 同步执行状态到 Notion
|
||||||
if: ${{ secrets.NOTION_TOKEN != '' }}
|
if: ${{ env.NOTION_TOKEN != '' }}
|
||||||
env:
|
env:
|
||||||
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
|
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
|
||||||
EXECUTION_LOG_DB_ID: ${{ secrets.EXECUTION_LOG_DB_ID }}
|
EXECUTION_LOG_DB_ID: ${{ secrets.EXECUTION_LOG_DB_ID }}
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,15 @@
|
||||||
* 功能:
|
* 功能:
|
||||||
* - 读取 Notion 广播
|
* - 读取 Notion 广播
|
||||||
* - 写回执行日志
|
* - 写回执行日志
|
||||||
* - 同步任务状态
|
* - 同步执行层状态
|
||||||
*
|
*
|
||||||
* 同步结构:
|
* 同步结构:
|
||||||
* Notion → 仓库(下行:读取广播/工单)
|
* Notion → 仓库(下行:读取广播/工单)
|
||||||
* 仓库 → Notion(上行:写回日志/状态)
|
* 仓库 → Notion(上行:写回日志/状态)
|
||||||
*
|
*
|
||||||
* 环境变量:
|
* 环境变量:
|
||||||
* NOTION_TOKEN — Notion API Token
|
* NOTION_TOKEN — Notion API Token
|
||||||
* BROADCAST_DB_ID — 广播数据库 ID
|
* BROADCAST_DB_ID — 广播数据库 ID(需包含 status 属性,值: 待执行/已完成)
|
||||||
* EXECUTION_LOG_DB_ID — 执行日志数据库 ID
|
* EXECUTION_LOG_DB_ID — 执行日志数据库 ID
|
||||||
*
|
*
|
||||||
* 调用方式:
|
* 调用方式:
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,9 @@ function isDuplicate(broadcastId) {
|
||||||
try {
|
try {
|
||||||
const memory = JSON.parse(fs.readFileSync(MEMORY_PATH, 'utf-8'));
|
const memory = JSON.parse(fs.readFileSync(MEMORY_PATH, 'utf-8'));
|
||||||
const events = memory.events || [];
|
const events = memory.events || [];
|
||||||
const today = new Date().toISOString().slice(0, 10);
|
|
||||||
|
|
||||||
return events.some(e =>
|
return events.some(e =>
|
||||||
e.broadcast_id === broadcastId ||
|
e.broadcast_id === broadcastId ||
|
||||||
(e.type === 'broadcast' && e.description === broadcastId) ||
|
(e.type === 'broadcast' && e.description === broadcastId)
|
||||||
(e.type === 'broadcast' && e.description === broadcastId && (e.date || '').startsWith(today))
|
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -223,11 +223,7 @@ async function syncToNotion(statusData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('📡 同步执行状态到 Notion...');
|
console.log('📡 同步执行状态到 Notion...');
|
||||||
await notionSync.pushExecutionLog({
|
await notionSync.syncExecutionStatus(statusData);
|
||||||
task_id: `execution-sync-${new Date().toISOString().slice(0, 10)}`,
|
|
||||||
status: statusData.execution_layer_status,
|
|
||||||
message: `v${statusData.version} | modules: ${statusData.core_modules.length} | workflows: ${statusData.workflows.count} | queue: ${statusData.task_queue.total}`
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CLI 入口
|
// CLI 入口
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,13 @@ function enqueue(task) {
|
||||||
// 去重:相同 task_id 只保留最新
|
// 去重:相同 task_id 只保留最新
|
||||||
const existing = queue.tasks.findIndex(t => t.task_id === task.task_id);
|
const existing = queue.tasks.findIndex(t => t.task_id === task.task_id);
|
||||||
if (existing !== -1) {
|
if (existing !== -1) {
|
||||||
queue.tasks[existing] = { ...task, updated_at: new Date().toISOString() };
|
const original = queue.tasks[existing];
|
||||||
|
queue.tasks[existing] = {
|
||||||
|
...original,
|
||||||
|
...task,
|
||||||
|
queued_at: original.queued_at,
|
||||||
|
updated_at: new Date().toISOString()
|
||||||
|
};
|
||||||
console.log(`🔄 更新已有任务: ${task.task_id}`);
|
console.log(`🔄 更新已有任务: ${task.task_id}`);
|
||||||
} else {
|
} else {
|
||||||
queue.tasks.push({
|
queue.tasks.push({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue