yohei0125 3 лет назад
Родитель
Сommit
19522f5212
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      packages/app/src/server/models/page-operation.ts

+ 7 - 5
packages/app/src/server/models/page-operation.ts

@@ -47,6 +47,8 @@ export interface IPageOperation {
   options?: IOptionsForResuming,
   incForUpdatingDescendantCount?: number,
   unprocessableExpiryDate: Date,
+
+  isProcessable(): Promise<boolean>
 }
 
 export interface PageOperationDocument extends IPageOperation, Document {}
@@ -136,11 +138,6 @@ schema.statics.deleteByActionTypes = async function(
   logger.info(`Deleted all PageOperation documents with actionType: [${actionTypes}]`);
 };
 
-schema.statics.isProcessable = function(pageOp: PageOperationDocument): boolean {
-  const { unprocessableExpiryDate } = pageOp;
-  return unprocessableExpiryDate == null || (unprocessableExpiryDate != null && new Date() > unprocessableExpiryDate);
-};
-
 /**
  * add TIME_TO_ADD_SEC to current time and update unprocessableExpiryDate with it
  */
@@ -149,4 +146,9 @@ schema.statics.extendExpiryDate = async function(operationId: ObjectIdLike): Pro
   await this.findByIdAndUpdate(operationId, { unprocessableExpiryDate: date });
 };
 
+schema.methods.isProcessable = function(): boolean {
+  const { unprocessableExpiryDate } = this;
+  return unprocessableExpiryDate == null || (unprocessableExpiryDate != null && new Date() > unprocessableExpiryDate);
+};
+
 export default getOrCreateModel<PageOperationDocument, PageOperationModel>('PageOperation', schema);