|
|
@@ -3065,22 +3065,6 @@ class PageService {
|
|
|
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
|
|
|
* - page that has the same path as the provided path
|
|
|
@@ -3112,6 +3096,22 @@ class PageService {
|
|
|
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 {
|
|
|
const socket = this.crowi.socketIoService.getDefaultSocket();
|
|
|
|