From aed05790eae9a3805423e92108ed1368392d9c08 Mon Sep 17 00:00:00 2001 From: xiongxiao Date: Wed, 18 Mar 2026 01:37:30 +0800 Subject: [PATCH] fix --- src/routes/cnb.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/routes/cnb.ts b/src/routes/cnb.ts index e534537..692d832 100644 --- a/src/routes/cnb.ts +++ b/src/routes/cnb.ts @@ -32,7 +32,9 @@ app.route({ topics: item.topics ? item.topics.split(',').filter(Boolean) : [], })) const repositories = _todayList.filter(item => item.topics.includes('gitea')); - app.run({ path: 'cnb', key: 'report', payload: { repoList: repositories } }); + if (_todayList.length > 5) { + app.run({ path: 'cnb', key: 'report', payload: { repoList: _todayList } }); + } ctx.body = { list: repositories } @@ -50,6 +52,7 @@ app.route({ }).define(async (ctx) => { const { repoList } = ctx.args; // 处理上报的仓库信息 + await closeOldReports(); if (Array.isArray(repoList)) { let infoTable = '| 仓库路径 | 仓库名称 | 仓库链接 | 仓库描述 | 仓库标签 |\n'; infoTable += '| --- | --- | --- | --- | --- |\n'; @@ -60,9 +63,25 @@ app.route({ console.log('上报的仓库信息表格:\n', infoTable); cnb.issue.createIssue('kevisual/kevisual', { title: `仓库信息上报 - ${dayjs().format('YYYY-MM-DD HH:mm:ss')}`, - content: `以下是上报的仓库信息:\n\n${infoTable}`, + body: `以下是上报的仓库信息:\n\n${infoTable}`, // @ts-ignore labels: ['report'] }) } -}).addTo(app) \ No newline at end of file +}).addTo(app) + +const closeOldReports = async () => { + const res = await cnb.issue.getList('kevisual/kevisual', { + state: 'open', + // @ts-ignore + labels: ['report'] + }); + const issues = res.data || []; + const oneDayAgo = dayjs().subtract(1, 'day'); + for (const issue of issues) { + const updatedAt = dayjs(issue.updated_at); + if (updatedAt.isBefore(oneDayAgo)) { + await cnb.issue.updateIssue('kevisual/kevisual', issue.number, { state: 'closed', state_reason: 'done' }); + } + } +} \ No newline at end of file