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

use 'bind' to bind pageBulkExportService to 'this'

Futa Arai 1 год назад
Родитель
Сommit
31b17d033f

+ 6 - 10
apps/app/src/features/page-bulk-export/server/service/page-bulk-export-job-cron.ts

@@ -47,11 +47,9 @@ class PageBulkExportJobCronService extends CronService {
       createdAt: { $lt: new Date(Date.now() - exportJobExpirationSeconds * 1000) },
       createdAt: { $lt: new Date(Date.now() - exportJobExpirationSeconds * 1000) },
     });
     });
 
 
-    await this.cleanUpAndDeleteBulkExportJobs(expiredExportJobs, async(job) => {
-      if (pageBulkExportService != null) {
-        pageBulkExportService.cleanUpExportJobResources(job);
-      }
-    });
+    if (pageBulkExportService != null) {
+      await this.cleanUpAndDeleteBulkExportJobs(expiredExportJobs, pageBulkExportService.cleanUpExportJobResources.bind(pageBulkExportService));
+    }
   }
   }
 
 
   /**
   /**
@@ -88,11 +86,9 @@ class PageBulkExportJobCronService extends CronService {
   async deleteFailedExportJobs() {
   async deleteFailedExportJobs() {
     const failedExportJobs = await PageBulkExportJob.find({ status: PageBulkExportJobStatus.failed });
     const failedExportJobs = await PageBulkExportJob.find({ status: PageBulkExportJobStatus.failed });
 
 
-    await this.cleanUpAndDeleteBulkExportJobs(failedExportJobs, async(job) => {
-      if (pageBulkExportService != null) {
-        pageBulkExportService.cleanUpExportJobResources(job);
-      }
-    });
+    if (pageBulkExportService != null) {
+      await this.cleanUpAndDeleteBulkExportJobs(failedExportJobs, pageBulkExportService.cleanUpExportJobResources.bind(pageBulkExportService));
+    }
   }
   }
 
 
   async cleanUpAndDeleteBulkExportJobs(
   async cleanUpAndDeleteBulkExportJobs(