From 2f7c920c46b0bc8f95799f844fc72945813816e6 Mon Sep 17 00:00:00 2001 From: "Anusheh Atif (anushehatiff)" Date: Tue, 24 Oct 2023 21:16:09 -0400 Subject: [PATCH 1/4] refer to 10/24/2023 --- backend/typescript/graphql/index.ts | 1 + .../graphql/resolvers/dashboardResolvers.ts | 8 +++ .../typescript/graphql/types/dashboardType.ts | 1 + .../implementations/appDashboardService.ts | 60 +++++++++++++++++++ .../interfaces/appDashboardService.ts | 1 + backend/typescript/types.ts | 1 + 6 files changed, 72 insertions(+) diff --git a/backend/typescript/graphql/index.ts b/backend/typescript/graphql/index.ts index ad2b1b4..a924a62 100644 --- a/backend/typescript/graphql/index.ts +++ b/backend/typescript/graphql/index.ts @@ -63,6 +63,7 @@ const graphQLMiddlewares = { simpleEntities: authorizedByAllRoles(), dashboardById: authorizedByAllRoles(), applicationsByRole: authorizedByAllRoles(), + applicationsById: authorizedByAllRoles(), applicationTable: authorizedByAllRoles(), userById: authorizedByAdmin(), userByEmail: authorizedByAdmin(), diff --git a/backend/typescript/graphql/resolvers/dashboardResolvers.ts b/backend/typescript/graphql/resolvers/dashboardResolvers.ts index 620d3b8..2f0dad3 100644 --- a/backend/typescript/graphql/resolvers/dashboardResolvers.ts +++ b/backend/typescript/graphql/resolvers/dashboardResolvers.ts @@ -26,6 +26,14 @@ const dashboardResolvers = { firstChoice, ); return applications; + },applicationsById: async ( + _parent: undefined, + { id }: { id: number }, + ): Promise => { + const application = await dashboardService.getApplicationsById( + id, + ); + return application; }, dashboardsByApplicationId: async ( _parent: undefined, diff --git a/backend/typescript/graphql/types/dashboardType.ts b/backend/typescript/graphql/types/dashboardType.ts index 19fb22c..aaac7da 100644 --- a/backend/typescript/graphql/types/dashboardType.ts +++ b/backend/typescript/graphql/types/dashboardType.ts @@ -59,6 +59,7 @@ const dashboardType = gql` extend type Query { dashboardById(id: Int!): ApplicationDashboardDTO! applicationsByRole(firstChoice: String!): [ApplicationDTO]! + applicationsById(id: Int!): [ApplicationDTO]! dashboardsByApplicationId(applicationId: Int!): [ApplicationDashboardDTO]! applicationTable(role: String!): [ApplicationDashboardRowDTO]! } diff --git a/backend/typescript/services/implementations/appDashboardService.ts b/backend/typescript/services/implementations/appDashboardService.ts index 967a492..fe2d26c 100644 --- a/backend/typescript/services/implementations/appDashboardService.ts +++ b/backend/typescript/services/implementations/appDashboardService.ts @@ -99,6 +99,66 @@ class AppDashboardService implements IAppDashboardService { return applicationsByRoleDTO; } +//Takes in an application id and returns an array of applicants with same id + async getApplicationsById(id: number): Promise { + let applications: Array | null; + let applicationById: Application |undefined; + let applicationByIdDTO: ApplicationDTO; + try { + applications = await Application.findAll(); + applicationById = applications.find(application => application.id == id); + + if (applicationById === undefined) { + // Handle the case when no application is found + throw new Error(`Application with id ${id} not found`); + } + + applicationByIdDTO = { + id: applicationById.id, + academicYear: applicationById.academicYear, + binaryQuestion1: applicationById.binaryQuestion1, + binaryQuestion2: applicationById.binaryQuestion2, + binaryQuestions: applicationById.binaryQuestions, + dropdownQuestion1: applicationById.dropdownQuestion1, + dropdownQuestions: applicationById.dropdownQuestions, + email: applicationById.email, + firstName: applicationById.firstName, + lastName: applicationById.lastName, + positions: applicationById.positions, + program: applicationById.program, + question1: applicationById.question1, + question2: applicationById.question2, + question3: applicationById.question3, + question4: applicationById.question4, + question5: applicationById.question5, + questions: applicationById.questions, + resume: applicationById.resume, + resumeInput: applicationById.resumeInput, + resumeUrl: applicationById.resumeUrl, + roleQuestion1: applicationById.roleQuestion1, + roleQuestion2: applicationById.roleQuestion2, + roleQuestion3: applicationById.roleQuestion3, + roleQuestion4: applicationById.roleQuestion4, + roleQuestion5: applicationById.roleQuestion5, + roleQuestion6: applicationById.roleQuestion6, + roleQuestion7: applicationById.roleQuestion7, + roleQuestion8: applicationById.roleQuestion8, + roleQuestion9: applicationById.roleQuestion9, + roleSpecificQuestions: applicationById.roleSpecificQuestions, + status: applicationById.status, + timestamp: applicationById.timestamp, + }; + } catch (error: unknown) { + Logger.error( + `Failed to get applications by id = ${id}. Reason = ${getErrorMessage( + error, + )}`, + ); + throw error; + } + return applicationByIdDTO; + } + async getDashboardsByApplicationId( applicationId: number, ): Promise { diff --git a/backend/typescript/services/interfaces/appDashboardService.ts b/backend/typescript/services/interfaces/appDashboardService.ts index f0a347b..74444bd 100644 --- a/backend/typescript/services/interfaces/appDashboardService.ts +++ b/backend/typescript/services/interfaces/appDashboardService.ts @@ -7,6 +7,7 @@ import { interface IAppDashboardService { getDashboardById(id: number): Promise; getApplicationsByRole(role: string): Promise; + getApplicationsById(id: number): Promise; getDashboardsByApplicationId( applicationId: number, ): Promise; diff --git a/backend/typescript/types.ts b/backend/typescript/types.ts index 6b2202f..da9a844 100644 --- a/backend/typescript/types.ts +++ b/backend/typescript/types.ts @@ -74,6 +74,7 @@ export type ApplicationDTO = { term: string; timesApplied: string; timestamp: bigint; + }; export type ApplicationDashboardRowDTO = { From dbf8b2d6318fa2217afe8ce64cda938372abe4d0 Mon Sep 17 00:00:00 2001 From: LucyWuu <89555431+LucyWuu@users.noreply.github.com> Date: Thu, 26 Oct 2023 21:41:16 -0400 Subject: [PATCH 2/4] 10/26/2023 --- .../typescript/graphql/types/dashboardType.ts | 2 +- .../migrations/applicationlist.json | 2 +- .../implementations/appDashboardService.ts | 53 +++++++------------ 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/backend/typescript/graphql/types/dashboardType.ts b/backend/typescript/graphql/types/dashboardType.ts index aaac7da..05749bd 100644 --- a/backend/typescript/graphql/types/dashboardType.ts +++ b/backend/typescript/graphql/types/dashboardType.ts @@ -59,7 +59,7 @@ const dashboardType = gql` extend type Query { dashboardById(id: Int!): ApplicationDashboardDTO! applicationsByRole(firstChoice: String!): [ApplicationDTO]! - applicationsById(id: Int!): [ApplicationDTO]! + applicationsById(id: Int!): ApplicationDTO! dashboardsByApplicationId(applicationId: Int!): [ApplicationDashboardDTO]! applicationTable(role: String!): [ApplicationDashboardRowDTO]! } diff --git a/backend/typescript/migrations/applicationlist.json b/backend/typescript/migrations/applicationlist.json index a24d6ef..bc8a3e6 100644 --- a/backend/typescript/migrations/applicationlist.json +++ b/backend/typescript/migrations/applicationlist.json @@ -134,4 +134,4 @@ "timesApplied": "This is my first time!", "timestamp": 1688143336170 } -] \ No newline at end of file +] diff --git a/backend/typescript/services/implementations/appDashboardService.ts b/backend/typescript/services/implementations/appDashboardService.ts index fe2d26c..8cde083 100644 --- a/backend/typescript/services/implementations/appDashboardService.ts +++ b/backend/typescript/services/implementations/appDashboardService.ts @@ -114,39 +114,26 @@ class AppDashboardService implements IAppDashboardService { } applicationByIdDTO = { - id: applicationById.id, - academicYear: applicationById.academicYear, - binaryQuestion1: applicationById.binaryQuestion1, - binaryQuestion2: applicationById.binaryQuestion2, - binaryQuestions: applicationById.binaryQuestions, - dropdownQuestion1: applicationById.dropdownQuestion1, - dropdownQuestions: applicationById.dropdownQuestions, - email: applicationById.email, - firstName: applicationById.firstName, - lastName: applicationById.lastName, - positions: applicationById.positions, - program: applicationById.program, - question1: applicationById.question1, - question2: applicationById.question2, - question3: applicationById.question3, - question4: applicationById.question4, - question5: applicationById.question5, - questions: applicationById.questions, - resume: applicationById.resume, - resumeInput: applicationById.resumeInput, - resumeUrl: applicationById.resumeUrl, - roleQuestion1: applicationById.roleQuestion1, - roleQuestion2: applicationById.roleQuestion2, - roleQuestion3: applicationById.roleQuestion3, - roleQuestion4: applicationById.roleQuestion4, - roleQuestion5: applicationById.roleQuestion5, - roleQuestion6: applicationById.roleQuestion6, - roleQuestion7: applicationById.roleQuestion7, - roleQuestion8: applicationById.roleQuestion8, - roleQuestion9: applicationById.roleQuestion9, - roleSpecificQuestions: applicationById.roleSpecificQuestions, - status: applicationById.status, - timestamp: applicationById.timestamp, + id: applicationById.id, + academicOrCoop: applicationById.academicOrCoop, + academicYear: applicationById.academicYear, + email: applicationById.email, + firstChoiceRole: applicationById.firstChoiceRole, + firstName: applicationById.firstName, + heardFrom: applicationById.heardFrom, + lastName: applicationById.lastName, + locationPreference: applicationById.locationPreference, + program: applicationById.program, + pronouns: applicationById.pronouns, + pronounsSpecified: applicationById.pronounsSpecified, + resumeUrl: applicationById.resumeUrl, + roleSpecificQuestions: applicationById.roleSpecificQuestions, + secondChoiceRole: applicationById.secondChoiceRole, + shortAnswerQuestions: applicationById.shortAnswerQuestions, + status: applicationById.status, + term: applicationById.term, + timesApplied: applicationById.timesApplied, + timestamp: applicationById.timestamp }; } catch (error: unknown) { Logger.error( From d029ae60172e58dcab058082ba3528e67c4689c4 Mon Sep 17 00:00:00 2001 From: "Anusheh Atif (anushehatiff)" Date: Tue, 7 Nov 2023 20:44:38 -0500 Subject: [PATCH 3/4] fixing application dto error --- .../implementations/appDashboardService.ts | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/backend/typescript/services/implementations/appDashboardService.ts b/backend/typescript/services/implementations/appDashboardService.ts index 8cde083..1c96199 100644 --- a/backend/typescript/services/implementations/appDashboardService.ts +++ b/backend/typescript/services/implementations/appDashboardService.ts @@ -100,52 +100,53 @@ class AppDashboardService implements IAppDashboardService { } //Takes in an application id and returns an array of applicants with same id - async getApplicationsById(id: number): Promise { +async getApplicationsById(id: number): Promise { let applications: Array | null; let applicationById: Application |undefined; let applicationByIdDTO: ApplicationDTO; - try { - applications = await Application.findAll(); - applicationById = applications.find(application => application.id == id); + // try { + // applications = await Application.findAll(); + // applicationById = applications.find(application => application.id == id); - if (applicationById === undefined) { - // Handle the case when no application is found - throw new Error(`Application with id ${id} not found`); - } + // if (applicationById === undefined) { + // // Handle the case when no application is found + // throw new Error(`Application with id ${id} not found`); + // } - applicationByIdDTO = { - id: applicationById.id, - academicOrCoop: applicationById.academicOrCoop, - academicYear: applicationById.academicYear, - email: applicationById.email, - firstChoiceRole: applicationById.firstChoiceRole, - firstName: applicationById.firstName, - heardFrom: applicationById.heardFrom, - lastName: applicationById.lastName, - locationPreference: applicationById.locationPreference, - program: applicationById.program, - pronouns: applicationById.pronouns, - pronounsSpecified: applicationById.pronounsSpecified, - resumeUrl: applicationById.resumeUrl, - roleSpecificQuestions: applicationById.roleSpecificQuestions, - secondChoiceRole: applicationById.secondChoiceRole, - shortAnswerQuestions: applicationById.shortAnswerQuestions, - status: applicationById.status, - term: applicationById.term, - timesApplied: applicationById.timesApplied, - timestamp: applicationById.timestamp - }; - } catch (error: unknown) { - Logger.error( - `Failed to get applications by id = ${id}. Reason = ${getErrorMessage( - error, - )}`, - ); - throw error; - } - return applicationByIdDTO; + // applicationByIdDTO = { + // id: applicationById.id, + // academicOrCoop: applicationById.academicOrCoop, + // academicYear: applicationById.academicYear, + // email: applicationById.email, + // firstChoiceRole: applicationById.firstChoiceRole, + // firstName: applicationById.firstName, + // heardFrom: applicationById.heardFrom, + // lastName: applicationById.lastName, + // locationPreference: applicationById.locationPreference, + // program: applicationById.program, + // pronouns: applicationById.pronouns, + // pronounsSpecified: applicationById.pronounsSpecified, + // resumeUrl: applicationById.resumeUrl, + // roleSpecificQuestions: applicationById.roleSpecificQuestions, + // secondChoiceRole: applicationById.secondChoiceRole, + // shortAnswerQuestions: applicationById.shortAnswerQuestions, + // status: applicationById.status, + // term: applicationById.term, + // timesApplied: applicationById.timesApplied, + // timestamp: applicationById.timestamp + // }; + // } catch (error: unknown) { + // Logger.error( + // `Failed to get applications by id = ${id}. Reason = ${getErrorMessage( + // error, + // )}`, + // ); + // throw error; + // } + return applicationByIdDTO; } + async getDashboardsByApplicationId( applicationId: number, ): Promise { From 18dd8000be426688e517939f398cd076531fde66 Mon Sep 17 00:00:00 2001 From: HeetShah Date: Tue, 7 Nov 2023 18:49:20 -0700 Subject: [PATCH 4/4] updates applicationsById query --- .../implementations/appDashboardService.ts | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/backend/typescript/services/implementations/appDashboardService.ts b/backend/typescript/services/implementations/appDashboardService.ts index 1c96199..68ce803 100644 --- a/backend/typescript/services/implementations/appDashboardService.ts +++ b/backend/typescript/services/implementations/appDashboardService.ts @@ -104,49 +104,49 @@ async getApplicationsById(id: number): Promise { let applications: Array | null; let applicationById: Application |undefined; let applicationByIdDTO: ApplicationDTO; - // try { - // applications = await Application.findAll(); - // applicationById = applications.find(application => application.id == id); + try { + applications = await Application.findAll(); + applicationById = applications.find(application => application.id == id); - // if (applicationById === undefined) { - // // Handle the case when no application is found - // throw new Error(`Application with id ${id} not found`); - // } + if (applicationById === undefined) { + // Handle the case when no application is found + throw new Error(`Application with id ${id} not found`); + } - // applicationByIdDTO = { - // id: applicationById.id, - // academicOrCoop: applicationById.academicOrCoop, - // academicYear: applicationById.academicYear, - // email: applicationById.email, - // firstChoiceRole: applicationById.firstChoiceRole, - // firstName: applicationById.firstName, - // heardFrom: applicationById.heardFrom, - // lastName: applicationById.lastName, - // locationPreference: applicationById.locationPreference, - // program: applicationById.program, - // pronouns: applicationById.pronouns, - // pronounsSpecified: applicationById.pronounsSpecified, - // resumeUrl: applicationById.resumeUrl, - // roleSpecificQuestions: applicationById.roleSpecificQuestions, - // secondChoiceRole: applicationById.secondChoiceRole, - // shortAnswerQuestions: applicationById.shortAnswerQuestions, - // status: applicationById.status, - // term: applicationById.term, - // timesApplied: applicationById.timesApplied, - // timestamp: applicationById.timestamp - // }; - // } catch (error: unknown) { - // Logger.error( - // `Failed to get applications by id = ${id}. Reason = ${getErrorMessage( - // error, - // )}`, - // ); - // throw error; - // } + applicationByIdDTO = { + id: applicationById.id, + academicOrCoop: applicationById.academicOrCoop, + academicYear: applicationById.academicYear, + email: applicationById.email, + firstChoiceRole: applicationById.firstChoiceRole, + firstName: applicationById.firstName, + heardFrom: applicationById.heardFrom, + lastName: applicationById.lastName, + locationPreference: applicationById.locationPreference, + program: applicationById.program, + pronouns: applicationById.pronouns, + pronounsSpecified: applicationById.pronounsSpecified, + resumeUrl: applicationById.resumeUrl, + roleSpecificQuestions: applicationById.roleSpecificQuestions, + secondChoiceRole: applicationById.secondChoiceRole, + shortAnswerQuestions: applicationById.shortAnswerQuestions, + secondChoiceStatus: applicationById.secondChoiceStatus, + status: applicationById.status, + term: applicationById.term, + timesApplied: applicationById.timesApplied, + timestamp: applicationById.timestamp + }; + } catch (error: unknown) { + Logger.error( + `Failed to get applications by id = ${id}. Reason = ${getErrorMessage( + error, + )}`, + ); + throw error; + } return applicationByIdDTO; } - async getDashboardsByApplicationId( applicationId: number, ): Promise {