|
|
@@ -47,6 +47,8 @@ export interface IPageOperation {
|
|
|
options?: IOptionsForResuming,
|
|
|
incForUpdatingDescendantCount?: number,
|
|
|
unprocessableExpiryDate: Date,
|
|
|
+
|
|
|
+ isProcessable(): boolean
|
|
|
}
|
|
|
|
|
|
export interface PageOperationDocument extends IPageOperation, Document {}
|
|
|
@@ -57,7 +59,6 @@ export interface PageOperationModel extends Model<PageOperationDocument> {
|
|
|
findByIdAndUpdatePageActionStage(pageOpId: ObjectIdLike, stage: PageActionStage): Promise<PageOperationDocumentHasId | null>
|
|
|
findMainOps(filter?: FilterQuery<PageOperationDocument>, projection?: any, options?: QueryOptions): Promise<PageOperationDocumentHasId[]>
|
|
|
deleteByActionTypes(deleteTypeList: PageActionType[]): Promise<void>
|
|
|
- isProcessable(pageOp: PageOperationDocument): boolean
|
|
|
extendExpiryDate(operationId: ObjectIdLike): Promise<void>
|
|
|
}
|
|
|
|
|
|
@@ -136,11 +137,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 +145,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);
|