This commit is contained in:
xiongxiao
2026-03-18 01:37:30 +08:00
committed by cnb
parent 5bf3a7a063
commit aed05790ea

View File

@@ -32,7 +32,9 @@ app.route({
topics: item.topics ? item.topics.split(',').filter(Boolean) : [], topics: item.topics ? item.topics.split(',').filter(Boolean) : [],
})) }))
const repositories = _todayList.filter(item => item.topics.includes('gitea')); 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 = { ctx.body = {
list: repositories list: repositories
} }
@@ -50,6 +52,7 @@ app.route({
}).define(async (ctx) => { }).define(async (ctx) => {
const { repoList } = ctx.args; const { repoList } = ctx.args;
// 处理上报的仓库信息 // 处理上报的仓库信息
await closeOldReports();
if (Array.isArray(repoList)) { if (Array.isArray(repoList)) {
let infoTable = '| 仓库路径 | 仓库名称 | 仓库链接 | 仓库描述 | 仓库标签 |\n'; let infoTable = '| 仓库路径 | 仓库名称 | 仓库链接 | 仓库描述 | 仓库标签 |\n';
infoTable += '| --- | --- | --- | --- | --- |\n'; infoTable += '| --- | --- | --- | --- | --- |\n';
@@ -60,9 +63,25 @@ app.route({
console.log('上报的仓库信息表格:\n', infoTable); console.log('上报的仓库信息表格:\n', infoTable);
cnb.issue.createIssue('kevisual/kevisual', { cnb.issue.createIssue('kevisual/kevisual', {
title: `仓库信息上报 - ${dayjs().format('YYYY-MM-DD HH:mm:ss')}`, title: `仓库信息上报 - ${dayjs().format('YYYY-MM-DD HH:mm:ss')}`,
content: `以下是上报的仓库信息:\n\n${infoTable}`, body: `以下是上报的仓库信息:\n\n${infoTable}`,
// @ts-ignore // @ts-ignore
labels: ['report'] labels: ['report']
}) })
} }
}).addTo(app) }).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' });
}
}
}