|
@@ -47,6 +47,8 @@ export interface IPageOperation {
|
|
|
options?: IOptionsForResuming,
|
|
options?: IOptionsForResuming,
|
|
|
incForUpdatingDescendantCount?: number,
|
|
incForUpdatingDescendantCount?: number,
|
|
|
unprocessableExpiryDate: Date,
|
|
unprocessableExpiryDate: Date,
|
|
|
|
|
+
|
|
|
|
|
+ isProcessable(): Promise<boolean>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface PageOperationDocument extends IPageOperation, Document {}
|
|
export interface PageOperationDocument extends IPageOperation, Document {}
|
|
@@ -136,11 +138,6 @@ schema.statics.deleteByActionTypes = async function(
|
|
|
logger.info(`Deleted all PageOperation documents with actionType: [${actionTypes}]`);
|
|
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
|
|
* 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 });
|
|
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);
|
|
export default getOrCreateModel<PageOperationDocument, PageOperationModel>('PageOperation', schema);
|