Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/search/progressive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const initSearch = async () => {
let totalEntitiesIndexed = 0;
let hasMore = true;
let fetchOffset = 0;
const entityNames = new Map<string, string>();

while (hasMore) {
const chunk = await repository.getAllEntities({ limit: CHUNK_SIZE, offset: fetchOffset });
Expand All @@ -94,6 +95,7 @@ export const initSearch = async () => {
const originalIds: string[] = [];

for (const entity of chunk) {
entityNames.set(entity.id!, entity.name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

docs.push(buildEntityDoc(entity));
originalIds.push(entity.id!);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.


Expand Down Expand Up @@ -126,7 +128,7 @@ export const initSearch = async () => {
for (const note of allNotes) {
if (note.content && note.content.trim().length > 0) {
const entityName = note.entity_id
? (await repository.getEntityById(note.entity_id))?.name
? entityNames.get(note.entity_id)
: undefined;
noteDocs.push(buildNoteDoc(note, entityName));
noteIds.push(note.id);
Expand Down
Loading