Skip to content

Commit

Permalink
Merge branch 'main' into INTF23-secondChoiceTab
Browse files Browse the repository at this point in the history
  • Loading branch information
Jess2772 authored Nov 15, 2023
2 parents 99e0779 + f7580fd commit 49295d8
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/typescript/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const graphQLMiddlewares = {
dashboardById: authorizedByAllRoles(),
applicationsByRole: authorizedByAllRoles(),
applicationsBySecondChoiceRole: authorizedByAllRoles(),
applicationsById: authorizedByAllRoles(),
applicationTable: authorizedByAllRoles(),
secondChoiceRoleApplicationTable: authorizedByAllRoles(),
userById: authorizedByAdmin(),
Expand Down
8 changes: 8 additions & 0 deletions backend/typescript/graphql/resolvers/dashboardResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ const dashboardResolvers = {
firstChoice,
);
return applications;
},applicationsById: async (
_parent: undefined,
{ id }: { id: number },
): Promise<ApplicationDTO> => {
const application = await dashboardService.getApplicationsById(
id,
);
return application;
},
applicationsBySecondChoiceRole: async (
_parent: undefined,
Expand Down
1 change: 1 addition & 0 deletions backend/typescript/graphql/types/dashboardType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const dashboardType = gql`
dashboardById(id: Int!): ApplicationDashboardDTO!
applicationsByRole(firstChoice: String!): [ApplicationDTO]!
applicationsBySecondChoiceRole(secondChoice: String!): [ApplicationDTO]!
applicationsById(id: Int!): ApplicationDTO!
dashboardsByApplicationId(applicationId: Int!): [ApplicationDashboardDTO]!
applicationTable(role: String!): [ApplicationDashboardRowDTO]!
secondChoiceRoleApplicationTable(role: String!): [ApplicationDashboardRowDTO]!
Expand Down
2 changes: 1 addition & 1 deletion backend/typescript/migrations/applicationlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@
"timesApplied": "This is my first time!",
"timestamp": 1688143336170
}
]
]
35 changes: 35 additions & 0 deletions backend/typescript/services/implementations/appDashboardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,41 @@ class AppDashboardService implements IAppDashboardService {
return applicationDashboardDTOs;
}

async getDashboardsByApplicationId(
applicationId: number,
): Promise<ApplicationDashboardDTO[]> {
let dashboards: ApplicationDashboardTable[] = [];
let applicationDashboardDTOs: Array<ApplicationDashboardDTO> = [];
try {
dashboards = await ApplicationDashboardTable.findAll({
where: { applicationId },
});
applicationDashboardDTOs = await dashboards.map((dashboard) => {
return {
id: dashboard.id,
reviewerEmail: dashboard.reviewerEmail,
passionFSG: dashboard.passionFSG,
teamPlayer: dashboard.teamPlayer,
desireToLearn: dashboard.desireToLearn,
skill: dashboard.skill,
skillCategory: dashboard.skillCategory,
reviewerComments: dashboard.reviewerComments,
recommendedSecondChoice: dashboard.recommendedSecondChoice,
reviewerId: dashboard.reviewerId,
applicationId: dashboard.applicationId,
};
});
} catch (error: unknown) {
Logger.error(
`Failed to get dashboards by this applicationId = ${applicationId}. Reason = ${getErrorMessage(
error,
)}`,
);
throw error;
}
return applicationDashboardDTOs;
}

async getApplicationDashboardTable(
role: ApplicantRole,
): Promise<ApplicationDashboardRowDTO[]> {
Expand Down
2 changes: 2 additions & 0 deletions backend/typescript/services/interfaces/appDashboardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface IAppDashboardService {
getDashboardById(id: number): Promise<ApplicationDashboardDTO>;
getApplicationsByRole(role: ApplicantRole): Promise<ApplicationDTO[]>;
getApplicationsBySecondChoiceRole(role: ApplicantRole): Promise<ApplicationDTO[]>;
getApplicationsByRole(role: string): Promise<ApplicationDTO[]>;
getApplicationsById(id: number): Promise<ApplicationDTO>;
getDashboardsByApplicationId(
applicationId: number,
): Promise<ApplicationDashboardDTO[]>;
Expand Down
1 change: 1 addition & 0 deletions backend/typescript/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export type ApplicationDTO = {
term: string;
timesApplied: string;
timestamp: bigint;

};

export type ApplicationDashboardRowDTO = {
Expand Down

0 comments on commit 49295d8

Please sign in to comment.