Shun Miyazawa пре 2 година
родитељ
комит
2631c49ea0
1 измењених фајлова са 5 додато и 7 уклоњено
  1. 5 7
      apps/app/src/server/service/page/index.ts

+ 5 - 7
apps/app/src/server/service/page/index.ts

@@ -3949,14 +3949,12 @@ class PageService implements IPageService {
     const Page = mongoose.model<PageDocument, PageModel>('Page');
 
     const ancestorPaths = collectAncestorPaths(path);
-    const builder = new PageQueryBuilder(Page.find());
-    const ancestorPages = await builder
-      .addConditionAsNonRootPage()
-      .addConditionToListByPathsArray(ancestorPaths)
-      .query
-      .exec();
+    const ancestorPageIds = await Page.aggregate([
+      { $match: { path: { $in: ancestorPaths, $nin: ['/'] }, isEmpty: false } },
+      { $project: { _id: 1 } },
+    ]);
 
-    const ancestorPageIds = ancestorPages.map(page => page._id);
+    // const ancestorPageIds = ancestorPages.map(page => page._id);
     await Page.updateMany({ _id: { $in: ancestorPageIds } }, { $unset: { ttlTimestamp: true } });
   }