Skip to content

Commit

Permalink
refactor(document/DocumentProcessor.ts): update batch processing logi…
Browse files Browse the repository at this point in the history
…c and add delay for stability

fix(main.ts): ensure notice is properly assigned before hiding it to avoid null reference errors
  • Loading branch information
anpigon committed Nov 29, 2024
1 parent 6fd7900 commit 1eead77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/helpers/document/DocumentProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,10 @@ export default class DocumentProcessor {
this.logger.debug("--→ updateData", updateData);

// Process updates in batches of 100
const updateBatchSize = 50;
for (let i = 0; i < updateData.length; i += updateBatchSize) {
const batch = updateData.slice(i, i + updateBatchSize);
this.logger.debug("--→ batch:updateData", batch);
for (let i = 0; i < updateData.length; i += batchSize) {
const batch = updateData.slice(i, i + batchSize);
await Promise.all(batch.map((data) => this.pineconeIndex.update(data)));
await new Promise((resolve) => setTimeout(resolve, 100));
}

this.logger.debug("saveToVectorStore update done");
Expand Down
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class SmartSeekerPlugin extends Plugin {
return;
}

let notice: Notice | null = null;
try {
this.isProcessingFolder = true;

Expand All @@ -126,21 +127,23 @@ export default class SmartSeekerPlugin extends Plugin {
`📚 ${folder.name} 폴더에서 ${files.length}개의 노트를 찾았습니다.`,
);

const notice = new Notice(
notice = new Notice(
"🔍 폴더 내 노트를 검색 데이터베이스에 추가하는 중...",
0,
);

const result = await this.documentProcessor.processMultiFiles(files);
this.logger.debug(`[Process] Completed:`, result);

notice.hide();
new Notice("✅ 모든 노트가 검색 데이터베이스에 추가되었습니다.");
} catch (error) {
this.logger.error("Error processing note:", error);
new Notice(`❌ 노트 처리 중 오류가 발생했습니다: ${error}`);
} finally {
this.isProcessingFolder = false;
if(notice) {
notice.hide();
}
}
}

Expand Down

0 comments on commit 1eead77

Please sign in to comment.