对比图完成

This commit is contained in:
cheney
2026-04-26 11:41:39 +08:00
parent 342042577d
commit becf0364ad
6 changed files with 216 additions and 34 deletions
+40 -4
View File
@@ -265,13 +265,50 @@ export async function trigger(startDate = null, endDate = null) {
return await checkAndFillSH300Data(startDate, endDate);
}
// 直接运行测试
function parseCommandLineArgs() {
const args = process.argv.slice(2);
let startDate = null;
let endDate = null;
for (let i = 0; i < args.length; i++) {
if (args[i] === '--start' && i + 1 < args.length) {
startDate = args[i + 1];
i++;
} else if (args[i] === '--end' && i + 1 < args.length) {
endDate = args[i + 1];
i++;
} else if (args[i] === '--help') {
console.log('使用方法:');
console.log(' bun sh300.scraper.js [选项]');
console.log('');
console.log('选项:');
console.log(' --start YYYY-MM-DD 指定开始日期');
console.log(' --end YYYY-MM-DD 指定结束日期');
console.log(' --help 显示帮助信息');
console.log('');
console.log('示例:');
console.log(' bun sh300.scraper.js');
console.log(' bun sh300.scraper.js --start 2024-01-01 --end 2024-01-31');
process.exit(0);
}
}
return { startDate, endDate };
}
async function runTest() {
console.log('='.repeat(60));
console.log('测试 sh300.scraper.js');
console.log('='.repeat(60));
// 测试配置读取
const { startDate, endDate } = parseCommandLineArgs();
if (startDate) {
console.log(`\n使用命令行参数:`);
console.log(` 开始日期: ${startDate}`);
console.log(` 结束日期: ${endDate || '默认'}`);
}
console.log('\n测试数据库配置读取...');
const config = loadDatabaseConfig();
console.log('配置读取结果:');
@@ -282,7 +319,7 @@ async function runTest() {
console.log('配置读取测试完成!');
try {
const result = await trigger();
const result = await trigger(startDate, endDate);
console.log('\n' + '='.repeat(60));
console.log('测试结果:');
console.log(` 开始日期: ${result.startDate}`);
@@ -298,5 +335,4 @@ async function runTest() {
}
}
// 运行测试
runTest();