Skip to content

Commit

Permalink
Merge pull request #100 from jsasitorn/subcollection-guard
Browse files Browse the repository at this point in the history
Move null filter in backfill to after await
  • Loading branch information
jasonbosco authored Dec 19, 2024
2 parents eb4c7a4 + 0f73ccc commit 61602aa
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions functions/src/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,20 @@ module.exports = functions.firestore.document(config.typesenseBackfillTriggerDoc
if (thisBatch.empty) {
break;
}
const currentDocumentsBatch = await Promise.all(
thisBatch.docs.map(async (doc) => {
const docPath = doc.ref.path;
const pathParams = utils.pathMatchesSelector(docPath, config.firestoreCollectionPath);

if (!isGroupQuery || (isGroupQuery && pathParams !== null)) {
return await utils.typesenseDocumentFromSnapshot(doc, pathParams);
} else {
return null;
}
}).filter((doc) => doc !== null));
const currentDocumentsBatch = (
await Promise.all(
thisBatch.docs.map(async (doc) => {
const docPath = doc.ref.path;
const pathParams = utils.pathMatchesSelector(docPath, config.firestoreCollectionPath);

if (!isGroupQuery || (isGroupQuery && pathParams !== null)) {
return await utils.typesenseDocumentFromSnapshot(doc, pathParams);
} else {
return null;
}
}),
)
).filter((doc) => doc !== null);

lastDoc = thisBatch.docs.at(-1) ?? null;
try {
Expand Down

0 comments on commit 61602aa

Please sign in to comment.