diff --git a/src/orientation/dto/orientation.dto.ts b/src/orientation/dto/orientation.dto.ts index c9de222f14af3cad15f436121b88917f1860aab5..9b4a2446ea3f0d7178d3500178621fec9b485d0e 100644 --- a/src/orientation/dto/orientation.dto.ts +++ b/src/orientation/dto/orientation.dto.ts @@ -136,8 +136,8 @@ export class OrientationDto { @Type(() => customStructureDto) structureOrientator: string | customStructureDto; - @ApiProperty({ enum: ['pending', 'acknowledged', 'completed'] }) + @ApiProperty({ enum: ['pending', 'acknowledged', 'completed', 'uncompleted', 'expired'] }) @IsNotEmpty() - @IsEnum(['pending', 'acknowledged', 'completed']) - status: 'pending' | 'acknowledged' | 'completed'; + @IsEnum(['pending', 'acknowledged', 'completed', 'uncompleted', 'expired']) + status: 'pending' | 'acknowledged' | 'completed' | 'uncompleted' | 'expired'; } diff --git a/src/orientation/orientation.schema.ts b/src/orientation/orientation.schema.ts index 7bd1d172811c1108efe44eb49703512e2afc52ef..d69cb673b9ac30f4386bef2e4b24f93e679d0fdb 100644 --- a/src/orientation/orientation.schema.ts +++ b/src/orientation/orientation.schema.ts @@ -98,7 +98,11 @@ export class Orientation { @Prop({ type: mongoose.Schema.Types.Mixed }) structureOrientator: string | customStructure; - @Prop({ required: true, enum: ['pending', 'acknowledged', 'completed'], default: 'pending' }) + @Prop({ + required: true, + enum: ['pending', 'acknowledged', 'completed', 'uncompleted', 'expired'], + default: 'pending', + }) status: string; } diff --git a/src/orientation/orientation.service.ts b/src/orientation/orientation.service.ts index f7e04c85f6ea8e9dd878a02d8e6638618f844b0f..e44b745145852e8d805444af975b7c92b8297a65 100644 --- a/src/orientation/orientation.service.ts +++ b/src/orientation/orientation.service.ts @@ -39,6 +39,7 @@ export class OrientationService { public async find(userId: string, structureId: string = null): Promise<any> { try { + const historyStatus = ['completed', 'uncompleted', 'expired']; let myOrientationsFilters; let todoOrientationsFilters; @@ -58,8 +59,14 @@ export class OrientationService { } return { - myOrientations: await this.findWithFilters(myOrientationsFilters), - todoOrientations: await this.findWithFilters(todoOrientationsFilters), + myOrientations: { + inProgress: await this.findWithFilters({ ...myOrientationsFilters, status: { $nin: historyStatus } }), + history: await this.findWithFilters({ ...myOrientationsFilters, status: { $in: historyStatus } }), + }, + todoOrientations: { + inProgress: await this.findWithFilters({ ...todoOrientationsFilters, status: { $nin: historyStatus } }), + history: await this.findWithFilters({ ...todoOrientationsFilters, status: { $in: historyStatus } }), + }, }; } catch (e) { this.logger.error(`Error fetching orientations with details: ${e.message}`);