Explorar el Código

change to instance methods

yohei0125 hace 3 años
padre
commit
19522f5212
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  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);