ソースを参照

rename shouldEmitAvailable to shouldEmitProgress

keigo-h 3 年 前
コミット
a6e7db1d1c

+ 1 - 1
packages/app/src/server/interfaces/search.ts

@@ -37,7 +37,7 @@ export type SearchableData<T = Partial<QueryTerms>> = {
 }
 
 export type UpdateOrInsertPagesOpts = {
-  shouldEmitAvailable?: boolean
+  shouldEmitProgress?: boolean
   invokeGarbageCollection?: boolean
 }
 

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

@@ -2708,7 +2708,7 @@ class PageService {
    * @param user To be used to filter pages to update. If null, only public pages will be updated.
    * @returns Promise<void>
    */
-  async normalizeParentRecursively(paths: string[], user: any | null, shouldEmitAvailable = false): Promise<number> {
+  async normalizeParentRecursively(paths: string[], user: any | null, shouldEmitProgress = false): Promise<number> {
     const Page = mongoose.model('Page') as unknown as PageModel;
 
     const ancestorPaths = paths.flatMap(p => collectAncestorPaths(p, []));
@@ -2727,7 +2727,7 @@ class PageService {
 
     const grantFiltersByUser: { $or: any[] } = Page.generateGrantCondition(user, userGroups);
 
-    return this._normalizeParentRecursively(pathAndRegExpsToNormalize, ancestorPaths, grantFiltersByUser, user, shouldEmitAvailable);
+    return this._normalizeParentRecursively(pathAndRegExpsToNormalize, ancestorPaths, grantFiltersByUser, user, shouldEmitProgress);
   }
 
   private buildFilterForNormalizeParentRecursively(pathOrRegExps: (RegExp | string)[], publicPathsToNormalize: string[], grantFiltersByUser: { $or: any[] }) {
@@ -2777,7 +2777,7 @@ class PageService {
       publicPathsToNormalize: string[],
       grantFiltersByUser: { $or: any[] },
       user,
-      shouldEmitAvailable = false,
+      shouldEmitProgress = false,
       count = 0,
       skiped = 0,
       isFirst = true,
@@ -2785,7 +2785,7 @@ class PageService {
     const BATCH_SIZE = 100;
     const PAGES_LIMIT = 1000;
 
-    const socket = shouldEmitAvailable ? this.crowi.socketIoService.getAdminSocket() : null;
+    const socket = shouldEmitProgress ? this.crowi.socketIoService.getAdminSocket() : null;
 
     const Page = mongoose.model('Page') as unknown as PageModel;
     const { PageQueryBuilder } = Page;
@@ -2955,7 +2955,7 @@ class PageService {
         publicPathsToNormalize,
         grantFiltersByUser,
         user,
-        shouldEmitAvailable,
+        shouldEmitProgress,
         nextCount,
         nextSkiped,
         false,

+ 5 - 5
packages/app/src/server/service/search-delegator/elasticsearch.ts

@@ -437,7 +437,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
 
   addAllPages() {
     const Page = mongoose.model('Page');
-    return this.updateOrInsertPages(() => Page.find(), { shouldEmitAvailable: true, invokeGarbageCollection: true });
+    return this.updateOrInsertPages(() => Page.find(), { shouldEmitProgress: true, invokeGarbageCollection: true });
   }
 
   updateOrInsertPageById(pageId) {
@@ -457,7 +457,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
    * @param {function} queryFactory factory method to generate a Mongoose Query instance
    */
   async updateOrInsertPages(queryFactory, option: UpdateOrInsertPagesOpts = {}) {
-    const { shouldEmitAvailable = false, invokeGarbageCollection = false } = option;
+    const { shouldEmitProgress = false, invokeGarbageCollection = false } = option;
 
     const Page = mongoose.model('Page') as unknown as PageModel;
     const { PageQueryBuilder } = Page;
@@ -465,7 +465,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
     const Comment = mongoose.model('Comment') as any; // TODO: typescriptize model
     const PageTagRelation = mongoose.model('PageTagRelation') as any; // TODO: typescriptize model
 
-    const socket = shouldEmitAvailable ? this.socketIoService.getAdminSocket() : null;
+    const socket = shouldEmitProgress ? this.socketIoService.getAdminSocket() : null;
 
     // prepare functions invoked from custom streams
     const prepareBodyForCreate = this.prepareBodyForCreate.bind(this);
@@ -583,7 +583,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
 
           logger.info(`Adding pages progressing: (count=${count}, errors=${res.errors}, took=${res.took}ms)`);
 
-          if (shouldEmitAvailable) {
+          if (shouldEmitProgress) {
             socket?.emit('addPageProgress', { totalCount, count, skipped });
           }
         }
@@ -607,7 +607,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
       final(callback) {
         logger.info(`Adding pages has completed: (totalCount=${totalCount}, skipped=${skipped})`);
 
-        if (shouldEmitAvailable) {
+        if (shouldEmitProgress) {
           socket?.emit('finishAddPage', { totalCount, count, skipped });
         }
         callback();