From 82f1aedda99418c07e9275adaea2b6641d5ba04e Mon Sep 17 00:00:00 2001 From: Rayna-Yu Date: Mon, 27 Jan 2025 10:30:09 -0500 Subject: [PATCH 1/2] first attempt to change application step --- apps/backend/src/applications/application.entity.ts | 11 ++++++++--- .../src/applications/applications.controller.ts | 12 +++++++++++- .../backend/src/applications/applications.service.ts | 9 +++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/applications/application.entity.ts b/apps/backend/src/applications/application.entity.ts index cf6ea457..85714307 100644 --- a/apps/backend/src/applications/application.entity.ts +++ b/apps/backend/src/applications/application.entity.ts @@ -18,6 +18,7 @@ import { import { GetApplicationResponseDTO } from './dto/get-application.response.dto'; import { Review } from '../reviews/review.entity'; import { GetAllApplicationResponseDTO } from './dto/get-all-application.response.dto'; +import { ApplicationStatus } from './dto/application-status'; @Entity() export class Application { @@ -70,13 +71,14 @@ export class Application { meanRatingChallenge, meanRatingTechnicalChallenge, meanRatingInterview, + applicationStep, ): GetAllApplicationResponseDTO { return { userId: this.user.id, firstName: this.user.firstName, lastName: this.user.lastName, stage: this.stage, - step: this.step, + step: applicationStep, position: this.position, createdAt: this.createdAt, meanRatingAllReviews, @@ -87,7 +89,10 @@ export class Application { }; } - toGetApplicationResponseDTO(numApps: number): GetApplicationResponseDTO { + toGetApplicationResponseDTO( + numApps: number, + applicationStep, + ): GetApplicationResponseDTO { return { id: this.id, createdAt: this.createdAt, @@ -95,7 +100,7 @@ export class Application { semester: this.semester, position: this.position, stage: this.stage, - step: this.step, + step: applicationStep, response: this.response, reviews: this.reviews, numApps, diff --git a/apps/backend/src/applications/applications.controller.ts b/apps/backend/src/applications/applications.controller.ts index de19340d..b8fb322a 100644 --- a/apps/backend/src/applications/applications.controller.ts +++ b/apps/backend/src/applications/applications.controller.ts @@ -21,6 +21,7 @@ import { getAppForCurrentCycle } from './utils'; import { UserStatus } from '../users/types'; import { Application } from './application.entity'; import { GetAllApplicationResponseDTO } from './dto/get-all-application.response.dto'; +import { ApplicationStep } from './types'; @Controller('apps') @UseInterceptors(CurrentUserInterceptor) @@ -103,6 +104,15 @@ export class ApplicationsController { ); } - return app.toGetApplicationResponseDTO(apps.length); + let applicationStep = null; + + // Tthe application step + if (app.reviews.length > 0) { + applicationStep = ApplicationStep.REVIEWED; + } else { + applicationStep = ApplicationStep.SUBMITTED; + } + + return app.toGetApplicationResponseDTO(apps.length, applicationStep); } } diff --git a/apps/backend/src/applications/applications.service.ts b/apps/backend/src/applications/applications.service.ts index da3a397d..596d62f2 100644 --- a/apps/backend/src/applications/applications.service.ts +++ b/apps/backend/src/applications/applications.service.ts @@ -150,6 +150,7 @@ export class ApplicationsService { let meanRatingChallenge = null; // Default to null for DESIGNERS let meanRatingTechnicalChallenge = null; let meanRatingInterview = null; + let applicationStep = null; // Calculate mean rating of all reviews if (app.reviews.length > 0) { @@ -204,12 +205,20 @@ export class ApplicationsService { interviewReviews.length; } + // Tthe application step + if (app.reviews.length > 0) { + applicationStep = ApplicationStep.REVIEWED; + } else { + applicationStep = ApplicationStep.SUBMITTED; + } + return app.toGetAllApplicationResponseDTO( meanRatingAllReviews, meanRatingResume, meanRatingChallenge, meanRatingTechnicalChallenge, meanRatingInterview, + applicationStep, ); }); From 77e29a8485be5563196c193c3850320d30ad632f Mon Sep 17 00:00:00 2001 From: Rayna-Yu Date: Mon, 27 Jan 2025 14:26:10 -0500 Subject: [PATCH 2/2] clean up --- apps/backend/src/applications/application.entity.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/backend/src/applications/application.entity.ts b/apps/backend/src/applications/application.entity.ts index 85714307..5bc315cb 100644 --- a/apps/backend/src/applications/application.entity.ts +++ b/apps/backend/src/applications/application.entity.ts @@ -18,7 +18,6 @@ import { import { GetApplicationResponseDTO } from './dto/get-application.response.dto'; import { Review } from '../reviews/review.entity'; import { GetAllApplicationResponseDTO } from './dto/get-all-application.response.dto'; -import { ApplicationStatus } from './dto/application-status'; @Entity() export class Application {