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 ──
|
||||
- name: 同步执行状态到 Notion
|
||||
if: ${{ secrets.NOTION_TOKEN != '' }}
|
||||
if: ${{ env.NOTION_TOKEN != '' }}
|
||||
env:
|
||||
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
|
||||
EXECUTION_LOG_DB_ID: ${{ secrets.EXECUTION_LOG_DB_ID }}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* 功能:
|
||||
* - 读取 Notion 广播
|
||||
* - 写回执行日志
|
||||
* - 同步任务状态
|
||||
* - 同步执行层状态
|
||||
*
|
||||
* 同步结构:
|
||||
* Notion → 仓库(下行:读取广播/工单)
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* 环境变量:
|
||||
* NOTION_TOKEN — Notion API Token
|
||||
* BROADCAST_DB_ID — 广播数据库 ID
|
||||
* BROADCAST_DB_ID — 广播数据库 ID(需包含 status 属性,值: 待执行/已完成)
|
||||
* EXECUTION_LOG_DB_ID — 执行日志数据库 ID
|
||||
*
|
||||
* 调用方式:
|
||||
|
|
|
|||
|
|
@ -97,12 +97,9 @@ function isDuplicate(broadcastId) {
|
|||
try {
|
||||
const memory = JSON.parse(fs.readFileSync(MEMORY_PATH, 'utf-8'));
|
||||
const events = memory.events || [];
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
|
||||
return events.some(e =>
|
||||
e.broadcast_id === broadcastId ||
|
||||
(e.type === 'broadcast' && e.description === broadcastId) ||
|
||||
(e.type === 'broadcast' && e.description === broadcastId && (e.date || '').startsWith(today))
|
||||
(e.type === 'broadcast' && e.description === broadcastId)
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -223,11 +223,7 @@ async function syncToNotion(statusData) {
|
|||
}
|
||||
|
||||
console.log('📡 同步执行状态到 Notion...');
|
||||
await notionSync.pushExecutionLog({
|
||||
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}`
|
||||
});
|
||||
await notionSync.syncExecutionStatus(statusData);
|
||||
}
|
||||
|
||||
// CLI 入口
|
||||
|
|
|
|||
|
|
@ -57,7 +57,13 @@ function enqueue(task) {
|
|||
// 去重:相同 task_id 只保留最新
|
||||
const existing = queue.tasks.findIndex(t => t.task_id === task.task_id);
|
||||
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}`);
|
||||
} else {
|
||||
queue.tasks.push({
|
||||
|
|
|
|||
Loading…
Reference in New Issue