From 724056e07b2055d45aed52ecb8cfab6c60946bb0 Mon Sep 17 00:00:00 2001 From: aanxniee Date: Tue, 28 Nov 2023 20:25:04 -0500 Subject: [PATCH 1/2] adds totalScore and adminComments field --- ...5T17.43.43.create-applicationDash-table.ts | 28 +++++++++++++------ .../models/applicationDashboard.model.ts | 16 +++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/backend/typescript/migrations/2023.04.05T17.43.43.create-applicationDash-table.ts b/backend/typescript/migrations/2023.04.05T17.43.43.create-applicationDash-table.ts index e133b4e..20090b3 100644 --- a/backend/typescript/migrations/2023.04.05T17.43.43.create-applicationDash-table.ts +++ b/backend/typescript/migrations/2023.04.05T17.43.43.create-applicationDash-table.ts @@ -11,11 +11,13 @@ const SEEDED_DATA = [ applicationId: 1, reviewerId: 1, reviewerEmail: userEmails[0], - passionFSG: 0, - teamPlayer: 0, - desireToLearn: 0, - skill: 0, + passionFSG: 2, + teamPlayer: 3, + desireToLearn: 2, + skill: 4, + totalScore: 11, reviewerComments: "Great job presenting your case study!", + adminComments: "Good!", recommendedSecondChoice: "N/A", skillCategory: "junior", }, @@ -23,11 +25,13 @@ const SEEDED_DATA = [ applicationId: 1, reviewerId: 2, reviewerEmail: userEmails[1], - passionFSG: 0, - teamPlayer: 0, - desireToLearn: 0, - skill: 0, + passionFSG: 5, + teamPlayer: 4, + desireToLearn: 4, + skill: 5, + totalScore: 18, reviewerComments: "Very good!", + adminComments: "Awesome job!", recommendedSecondChoice: "considered", skillCategory: "intermediate", }, @@ -78,6 +82,10 @@ export const up: Migration = async ({ context: sequelize }) => { type: DataType.INTEGER, allowNull: false, }, + totalScore: { + type: DataType.INTEGER, + allowNull: false, + }, skillCategory: { type: DataType.ENUM("junior", "intermediate", "senior"), allowNull: false, @@ -86,6 +94,10 @@ export const up: Migration = async ({ context: sequelize }) => { type: DataType.STRING, allowNull: false, }, + adminComments: { + type: DataType.STRING, + allowNull: false, + }, recommendedSecondChoice: { type: DataType.ENUM("N/A", "considered", "not considered"), allowNull: false, diff --git a/backend/typescript/models/applicationDashboard.model.ts b/backend/typescript/models/applicationDashboard.model.ts index 7b3e5ba..9fb80ba 100644 --- a/backend/typescript/models/applicationDashboard.model.ts +++ b/backend/typescript/models/applicationDashboard.model.ts @@ -7,6 +7,7 @@ import { ForeignKey, Model, Table, + BeforeSave, } from "sequelize-typescript"; import Application from "./application.model"; import User from "./user.model"; @@ -58,4 +59,19 @@ export default class ApplicationDashboardTable extends Model { @BelongsTo(() => Application) application!: Application; + + @Column({ type: DataType.STRING }) + adminComments!: string; + + @Column({ type: DataType.INTEGER }) + totalScore!: number; + + @BeforeSave + static calculateTotalScore(instance: ApplicationDashboardTable) { + instance.totalScore = + instance.passionFSG + + instance.desireToLearn + + instance.skill + + instance.teamPlayer; + } } From fbe8bce4e1bf40d1cdd649871756fd0573ae2488 Mon Sep 17 00:00:00 2001 From: aanxniee Date: Tue, 5 Dec 2023 19:44:15 -0500 Subject: [PATCH 2/2] adds new fields to graphql query --- .../graphql/resolvers/dashboardResolvers.ts | 11 +++-- .../typescript/graphql/types/dashboardType.ts | 2 + .../implementations/appDashboardService.ts | 43 ++++++++++++------- .../interfaces/appDashboardService.ts | 11 +++-- backend/typescript/types.ts | 2 + 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/backend/typescript/graphql/resolvers/dashboardResolvers.ts b/backend/typescript/graphql/resolvers/dashboardResolvers.ts index d6ec50f..4d5d2b5 100644 --- a/backend/typescript/graphql/resolvers/dashboardResolvers.ts +++ b/backend/typescript/graphql/resolvers/dashboardResolvers.ts @@ -39,9 +39,8 @@ const dashboardResolvers = { _parent: undefined, { secondChoice }: { secondChoice: ApplicantRole }, ): Promise> => { - const applications = await dashboardService.getApplicationsBySecondChoiceRole( - secondChoice, - ); + const applications = + await dashboardService.getApplicationsBySecondChoiceRole(secondChoice); return applications; }, dashboardsByApplicationId: async ( @@ -79,8 +78,10 @@ const dashboardResolvers = { teamPlayer, desireToLearn, skill, + totalScore, skillCategory, reviwerComments, + adminComments, recommendedSecondChoice, }: { reviewerEmail: string; @@ -90,8 +91,10 @@ const dashboardResolvers = { teamPlayer: number; desireToLearn: number; skill: number; + totalScore: number; skillCategory: string; reviwerComments: string; + adminComments: string; recommendedSecondChoice: string; }, ): Promise => { @@ -103,8 +106,10 @@ const dashboardResolvers = { teamPlayer, desireToLearn, skill, + totalScore, skillCategory, reviwerComments, + adminComments, recommendedSecondChoice, ); }, diff --git a/backend/typescript/graphql/types/dashboardType.ts b/backend/typescript/graphql/types/dashboardType.ts index 73ad49b..2e38657 100644 --- a/backend/typescript/graphql/types/dashboardType.ts +++ b/backend/typescript/graphql/types/dashboardType.ts @@ -90,8 +90,10 @@ const dashboardType = gql` teamPlayer: Int! desireToLearn: Int! skill: Int! + totalScore: Int! skillCategory: String! reviwerComments: String! + adminComments: String! recommendedSecondChoice: String! ): ApplicationDashboardDTO! } diff --git a/backend/typescript/services/implementations/appDashboardService.ts b/backend/typescript/services/implementations/appDashboardService.ts index b8b80b9..56deda5 100644 --- a/backend/typescript/services/implementations/appDashboardService.ts +++ b/backend/typescript/services/implementations/appDashboardService.ts @@ -47,8 +47,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: dashboard.teamPlayer, desireToLearn: dashboard.desireToLearn, skill: dashboard.skill, + totalScore: dashboard.totalScore, skillCategory: dashboard.skillCategory, reviewerComments: dashboard.reviewerComments, + adminComments: dashboard.adminComments, recommendedSecondChoice: dashboard.recommendedSecondChoice, reviewerId: dashboard.reviewerId, applicationId: dashboard.applicationId, @@ -166,8 +168,8 @@ class AppDashboardService implements IAppDashboardService { ); }, ); - applicationsBySecondChoiceRoleDTO = await applicationsBySecondChoiceRole.map( - (application) => { + applicationsBySecondChoiceRoleDTO = + await applicationsBySecondChoiceRole.map((application) => { return { id: application.id, academicOrCoop: application.academicOrCoop, @@ -191,8 +193,7 @@ class AppDashboardService implements IAppDashboardService { timesApplied: application.timesApplied, timestamp: application.timestamp, }; - }, - ); + }); } catch (error: unknown) { Logger.error( `Failed to get applications by this second choice role = ${role}. Reason = ${getErrorMessage( @@ -221,8 +222,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: dashboard.teamPlayer, desireToLearn: dashboard.desireToLearn, skill: dashboard.skill, + totalScore: dashboard.totalScore, skillCategory: dashboard.skillCategory, reviewerComments: dashboard.reviewerComments, + adminComments: dashboard.adminComments, recommendedSecondChoice: dashboard.recommendedSecondChoice, reviewerId: dashboard.reviewerId, applicationId: dashboard.applicationId, @@ -243,15 +246,13 @@ class AppDashboardService implements IAppDashboardService { role: ApplicantRole, ): Promise { // get all the applications for the role - const applications: Array = await this.getApplicationsByRole( - role, - ); + const applications: Array = + await this.getApplicationsByRole(role); // get the dashboards associated with the applications const appDashRows: Array = await Promise.all( applications.map(async (application) => { - const reviewDashboards: Array = await this.getDashboardsByApplicationId( - application.id, - ); + const reviewDashboards: Array = + await this.getDashboardsByApplicationId(application.id); const reviewers: Array = await Promise.all( reviewDashboards.map(async (dash) => { return userService.getUserByEmail(dash.reviewerEmail); @@ -271,15 +272,13 @@ class AppDashboardService implements IAppDashboardService { role: ApplicantRole, ): Promise { // get all the applications for the role - const applications: Array = await this.getApplicationsBySecondChoiceRole( - role, - ); + const applications: Array = + await this.getApplicationsBySecondChoiceRole(role); // get the dashboards associated with the applications const appDashRows: Array = await Promise.all( applications.map(async (application) => { - const reviewDashboards: Array = await this.getDashboardsByApplicationId( - application.id, - ); + const reviewDashboards: Array = + await this.getDashboardsByApplicationId(application.id); const reviewers: Array = await Promise.all( reviewDashboards.map(async (dash) => { return userService.getUserByEmail(dash.reviewerEmail); @@ -331,8 +330,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: dashboard.teamPlayer, desireToLearn: dashboard.desireToLearn, skill: dashboard.skill, + totalScore: dashboard.totalScore, skillCategory: dashboard.skillCategory, reviewerComments: dashboard.reviewerComments, + adminComments: dashboard.adminComments, recommendedSecondChoice: dashboard.recommendedSecondChoice, reviewerId: dashboard.reviewerId, applicationId: dashboard.applicationId, @@ -347,8 +348,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: number, desireToLearn: number, skill: number, + totalScore: number, skillCategory: string, reviewerComments: string, + adminComments: string, recommendedSecondChoice: string, ): Promise { try { @@ -363,8 +366,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer, desireToLearn, skill, + totalScore, skillCategory, reviewerComments, + adminComments, recommendedSecondChoice, }); Logger.error(`the data: ${JSON.stringify(dashboard)}`); @@ -375,8 +380,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: dashboard.teamPlayer, desireToLearn: dashboard.desireToLearn, skill: dashboard.skill, + totalScore: dashboard.totalScore, skillCategory: dashboard.skillCategory, reviewerComments: dashboard.reviewerComments, + adminComments: dashboard.adminComments, recommendedSecondChoice: dashboard.recommendedSecondChoice, reviewerId: dashboard.reviewerId, applicationId: dashboard.applicationId, @@ -413,8 +420,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: dashboard.teamPlayer, desireToLearn: dashboard.desireToLearn, skill: dashboard.skill, + totalScore: dashboard.totalScore, skillCategory: dashboard.skillCategory, reviewerComments: dashboard.reviewerComments, + adminComments: dashboard.adminComments, recommendedSecondChoice: dashboard.recommendedSecondChoice, reviewerId: dashboard.reviewerId, applicationId: dashboard.applicationId, @@ -447,8 +456,10 @@ class AppDashboardService implements IAppDashboardService { teamPlayer: dashboard.teamPlayer, desireToLearn: dashboard.desireToLearn, skill: dashboard.skill, + totalScore: dashboard.totalScore, skillCategory: dashboard.skillCategory, reviewerComments: dashboard.reviewerComments, + adminComments: dashboard.adminComments, recommendedSecondChoice: dashboard.recommendedSecondChoice, reviewerId: dashboard.reviewerId, applicationId: dashboard.applicationId, diff --git a/backend/typescript/services/interfaces/appDashboardService.ts b/backend/typescript/services/interfaces/appDashboardService.ts index 3c34515..8ce746f 100644 --- a/backend/typescript/services/interfaces/appDashboardService.ts +++ b/backend/typescript/services/interfaces/appDashboardService.ts @@ -36,11 +36,14 @@ interface IAppDashboardService { * @Param reviewerEmail the email of the reviewer * @param applicationId the id of the application (seperate from the postgres id field of the application) * @param reviewerAuthId the Firebase auth id of the user (This is NOT the same as the postgress id field of the user) - * @param passionFSG passion for social good rating of applicatn - * @param teamPlayer teamwork rating of applicatn - * @param skill skill rating of applicatn + * @param passionFSG passion for social good rating of application + * @param teamPlayer teamwork rating of application + * @param desireToLearn willingness to learn rating of application + * @param skill skill rating of application + * @param totalScore sum of passionFSG, teamPlayer, desireToLearn, and skill * @param skillCategory whether applicant is viewed as junior, intermediate, or senior * @param reviewerComments comments of the application from reviewer + * @param adminComments comments of the application from admin * @param recommendedSecondChoice an indication of whether 2nd choice is recommended * @param reviewComplete whether the reviewer has finished the review * @returns an array of the updated dashboard entry ids @@ -54,8 +57,10 @@ interface IAppDashboardService { teamPlayer: number, desireToLearn: number, skill: number, + totalScore: number, skillCategory: string, reviewerComments: string, + adminComments: string, recommendedSecondChoice: string, ): Promise; diff --git a/backend/typescript/types.ts b/backend/typescript/types.ts index d1299dd..266c3ed 100644 --- a/backend/typescript/types.ts +++ b/backend/typescript/types.ts @@ -39,8 +39,10 @@ export type ApplicationDashboardDTO = { teamPlayer: number; desireToLearn: number; skill: number; + totalScore: number; skillCategory: string; reviewerComments: string; + adminComments: string; recommendedSecondChoice: string; reviewerId: number; applicationId: number;