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

change method name and add coments

yohei0125 4 лет назад
Родитель
Сommit
7058c3e4b4
2 измененных файлов с 4 добавлено и 3 удалено
  1. 2 1
      packages/app/src/server/models/page.ts
  2. 2 2
      packages/app/src/server/service/page.js

+ 2 - 1
packages/app/src/server/models/page.ts

@@ -390,7 +390,8 @@ schema.statics.recountDescendantCountOfAncestors = async function(path:string, c
   await this.bulkWrite(operations);
 };
 
-schema.statics.recountPage = async function(id:mongoose.Types.ObjectId):Promise<void> {
+// update descendantCount of page with provided id
+schema.statics.recountDescendantCountOfSelfAndDescendants = async function(id:mongoose.Types.ObjectId):Promise<void> {
   const res = await this.aggregate(
     [
       {

+ 2 - 2
packages/app/src/server/service/page.js

@@ -1263,7 +1263,7 @@ class PageService {
    * - page that has the same path as the provided path
    * - pages that are descendants of the above page
    */
-  async updateSelfAndDescendantCount(path = '/') {
+  async updateDescendantCountOfSelfAndDescendants(path = '/') {
     const BATCH_SIZE = 200;
     const Page = this.crowi.model('Page');
 
@@ -1275,7 +1275,7 @@ class PageService {
       async write(pageDocuments, encoding, callback) {
         for (const document of pageDocuments) {
           // eslint-disable-next-line no-await-in-loop
-          await Page.recountPage(document._id);
+          await Page.recountDescendantCountOfSelfAndDescendants(document._id);
         }
         callback();
       },