Skip to content

Commit cca759b

Browse files
committed
feat: log clear
1 parent d612497 commit cca759b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

scripts/utils/data-importer.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,27 @@ export class DataImporter {
4747

4848
if (!org.name) {
4949
console.log(`跳过无名称的组织`);
50+
this.logger.logSkipped(org, '无名称');
5051
this.stats.skipped++;
5152
continue;
5253
}
54+
const nameKey = org.name.trim();
5355

5456
// 检查小型缓存
55-
if (smallCache.has(org.name)) {
56-
console.log(`跳过批次内重复: ${org.name}`);
57+
if (smallCache.has(nameKey)) {
58+
console.log(`跳过批次内重复: ${nameKey}`);
5759
this.logger.logSkipped(org, '批次内重复');
5860
this.stats.skipped++;
5961
continue;
6062
}
6163

6264
// 检查数据库中是否已存在(避免大内存缓存)
63-
const existing = await this.api.findOrganizationByName(org.name);
65+
const existing = await this.api.findOrganizationByName(nameKey);
6466
if (existing) {
65-
console.log(`跳过已存在的组织: ${org.name}`);
67+
console.log(`跳过已存在的组织: ${nameKey}`);
6668
this.logger.logSkipped(org, '组织已存在');
6769
this.stats.skipped++;
68-
smallCache.add(org.name); // 添加到小型缓存
70+
smallCache.add(nameKey); // 添加到小型缓存
6971
continue;
7072
}
7173

@@ -74,9 +76,9 @@ export class DataImporter {
7476
let createdOrganization: any = null;
7577

7678
if (this.dryRun) {
77-
console.log(`[DRY RUN] 将创建组织: ${org.name}`);
79+
console.log(`[DRY RUN] 将创建组织: ${nameKey}`);
7880
this.stats.success++;
79-
smallCache.add(org.name);
81+
smallCache.add(nameKey);
8082
continue;
8183
}
8284

@@ -85,11 +87,11 @@ export class DataImporter {
8587
delete (cleanOrgData as any)._originalData;
8688

8789
createdOrganization = await this.api.createOrganization(cleanOrgData);
88-
console.log(`✓ 成功创建组织: ${org.name}`);
90+
console.log(`✓ 成功创建组织: ${nameKey}`);
8991
this.stats.success++;
90-
smallCache.add(org.name);
92+
smallCache.add(nameKey);
9193
} catch (error: any) {
92-
console.error(`✗ 创建组织失败: ${org.name}`, error.message);
94+
console.error(`✗ 创建组织失败: ${nameKey}`, error.message);
9395
this.logger.logFailed(org, error);
9496
this.stats.failed++;
9597
}

0 commit comments

Comments
 (0)