Преглед изворни кода

refactor CollectionProgress

Yuki Takei пре 6 година
родитељ
комит
cd46a18600

+ 2 - 2
src/server/models/vo/collection-progress.js

@@ -1,4 +1,4 @@
-class ExportingProgress {
+class CollectionProgress {
 
   constructor(collectionName, totalCount) {
     this.collectionName = collectionName;
@@ -8,4 +8,4 @@ class ExportingProgress {
 
 }
 
-module.exports = ExportingProgress;
+module.exports = CollectionProgress;

+ 2 - 2
src/server/models/vo/collection-progressing-status.js

@@ -1,5 +1,5 @@
 const mongoose = require('mongoose');
-const ExportingProgress = require('./collection-progress');
+const CollectionProgress = require('./collection-progress');
 
 class CollectionProgressingStatus {
 
@@ -14,7 +14,7 @@ class CollectionProgressingStatus {
     const promisesForCreatingInstance = collections.map(async(collectionName) => {
       const collection = mongoose.connection.collection(collectionName);
       const totalCount = await collection.count();
-      return new ExportingProgress(collectionName, totalCount);
+      return new CollectionProgress(collectionName, totalCount);
     });
     this.progressList = await Promise.all(promisesForCreatingInstance);
 

+ 5 - 5
src/server/service/export.js

@@ -223,14 +223,14 @@ class ExportService {
    *
    * @memberOf ExportService
    *
-   * @param {ExportProgress} exportProgress
+   * @param {CollectionProgress} collectionProgress
    * @param {number} currentCount number of items exported
    */
-  logProgress(exportProgress, currentCount) {
-    const output = `${exportProgress.collectionName}: ${currentCount}/${exportProgress.totalCount} written`;
+  logProgress(collectionProgress, currentCount) {
+    const output = `${collectionProgress.collectionName}: ${currentCount}/${collectionProgress.totalCount} written`;
 
     // update exportProgress.currentCount
-    exportProgress.currentCount = currentCount;
+    collectionProgress.currentCount = currentCount;
 
     // output every this.per items
     if (currentCount % this.per === 0) {
@@ -238,7 +238,7 @@ class ExportService {
       this.emitProgressEvent();
     }
     // output last item
-    else if (currentCount === exportProgress.totalCount) {
+    else if (currentCount === collectionProgress.totalCount) {
       logger.info(output);
       this.emitProgressEvent();
     }