Просмотр исходного кода

Merge branch 'feat/integrate-recount-descendant-count-after-paths-fix' into feat/fix-error-in-resume-rename-operation

yohei0125 3 лет назад
Родитель
Сommit
72bc426523

+ 2 - 3
packages/app/src/server/service/page-operation.ts

@@ -174,9 +174,8 @@ class PageOperationService {
   getAncestorsPathsByFromAndToPath(fromPath: string, toPath: string): string[] {
     const fromAncestorsPaths = collectAncestorPaths(fromPath);
     const toAncestorsPaths = collectAncestorPaths(toPath);
-    // merge duplicate paths
-    const mergedPaths = Array.from(new Set(toAncestorsPaths.concat(fromAncestorsPaths)));
-    return mergedPaths;
+    // merge duplicate paths and return paths of ancestors
+    return Array.from(new Set(toAncestorsPaths.concat(fromAncestorsPaths)));
   }
 
   async getRenameSubOperationByPageId(pageId: ObjectIdLike): Promise<PageOperationDocument | null> {

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

@@ -3070,7 +3070,7 @@ class PageService {
     builder.addConditionToSortPagesByDescPath();
 
     const aggregatedPages = await builder.query.lean().cursor({ batchSize: BATCH_SIZE });
-    await this.recountAndUpdateDescendantCountOfPages(aggregatedPages);
+    await this.recountAndUpdateDescendantCountOfPages(aggregatedPages, BATCH_SIZE);
   }
 
   /**
@@ -3086,13 +3086,13 @@ class PageService {
     builder.addConditionToSortPagesByDescPath(); // sort in DESC
 
     const aggregatedPages = await builder.query.lean().cursor({ batchSize: BATCH_SIZE });
-    await this.recountAndUpdateDescendantCountOfPages(aggregatedPages);
+    await this.recountAndUpdateDescendantCountOfPages(aggregatedPages, BATCH_SIZE);
   }
 
   /**
    * Recount descendantCount of pages one by one
    */
-  async recountAndUpdateDescendantCountOfPages(pageCursor: QueryCursor<any>, batchSize?:number): Promise<void> {
+  async recountAndUpdateDescendantCountOfPages(pageCursor: QueryCursor<any>, batchSize:number): Promise<void> {
     const Page = this.crowi.model('Page');
     const recountWriteStream = new Writable({
       objectMode: true,