yohei0125 3 лет назад
Родитель
Сommit
62d0c3dfca
1 измененных файлов с 16 добавлено и 16 удалено
  1. 16 16
      packages/app/src/server/service/page.ts

+ 16 - 16
packages/app/src/server/service/page.ts

@@ -3065,22 +3065,6 @@ class PageService {
     await streamToPromise(recountWriteStream);
     await streamToPromise(recountWriteStream);
   }
   }
 
 
-  /**
-   * update descendantCount of the pages sequentially from path containing more `/` to path containing less
-   */
-  async updateDescendantCountOfPagesWithPaths(paths: string[]): Promise<void> {
-    const BATCH_SIZE = 200;
-    const Page = this.crowi.model('Page');
-    const { PageQueryBuilder } = Page;
-
-    const builder = new PageQueryBuilder(Page.find(), true);
-    builder.addConditionToListByPathsArray(paths); // find by paths
-    builder.addConditionToSortPagesByDescPath(); // sort in DESC
-
-    const aggregatedPages = await builder.query.lean().cursor({ batchSize: BATCH_SIZE });
-    await this.recountAndUpdateDescendantCountOfPages(aggregatedPages);
-  }
-
   /**
   /**
    * update descendantCount of the following pages
    * update descendantCount of the following pages
    * - page that has the same path as the provided path
    * - page that has the same path as the provided path
@@ -3112,6 +3096,22 @@ class PageService {
     this.emitUpdateDescCount(updateDescCountData);
     this.emitUpdateDescCount(updateDescCountData);
   }
   }
 
 
+  /**
+   * update descendantCount of the pages sequentially from path containing more `/` to path containing less
+   */
+  async updateDescendantCountOfPagesWithPaths(paths: string[]): Promise<void> {
+    const BATCH_SIZE = 200;
+    const Page = this.crowi.model('Page');
+    const { PageQueryBuilder } = Page;
+
+    const builder = new PageQueryBuilder(Page.find(), true);
+    builder.addConditionToListByPathsArray(paths); // find by paths
+    builder.addConditionToSortPagesByDescPath(); // sort in DESC
+
+    const aggregatedPages = await builder.query.lean().cursor({ batchSize: BATCH_SIZE });
+    await this.recountAndUpdateDescendantCountOfPages(aggregatedPages);
+  }
+
   private emitUpdateDescCount(data: UpdateDescCountRawData): void {
   private emitUpdateDescCount(data: UpdateDescCountRawData): void {
     const socket = this.crowi.socketIoService.getDefaultSocket();
     const socket = this.crowi.socketIoService.getDefaultSocket();