Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add review complete to applicationdashboardtable #38

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/typescript/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import userResolvers from "./resolvers/userResolvers";
import userType from "./types/userType";
import dashboardType from "./types/dashboardType";
import dashboardResolvers from "./resolvers/dashboardResolvers";
import reviewType from "./types/reviewType";

const query = gql`
type Query {
Expand All @@ -35,6 +36,7 @@ const executableSchema = makeExecutableSchema({
query,
mutation,
authType,
reviewType,
entityType,
simpleEntityType,
userType,
Expand Down
12 changes: 12 additions & 0 deletions backend/typescript/graphql/resolvers/authResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import FirebaseRestClient from "../../utilities/firebaseRestClient";
import IUserService from "../../services/interfaces/userService";
import User from "../../models/user.model";
import { AuthDTO, RegisterUserDTO, Role } from "../../types";
import IReviewService from "../../services/interfaces/reviewService";
import ReviewService from "../../services/implementations/reviewService";

const userService: IUserService = new UserService();
const emailService: IEmailService = new EmailService(nodemailerConfig);
const authService: IAuthService = new AuthService(userService, emailService);
const reviewService: IReviewService = new ReviewService();

const cookieOptions: CookieOptions = {
httpOnly: true,
Expand Down Expand Up @@ -51,6 +54,15 @@ const authResolvers = {
);
return isAuthorized;
},
isAuthorizedToReview: async (
_parent: undefined,
{
applicationId,
reviewerUserId,
}: { applicationId: number; reviewerUserId: string },
): Promise<boolean> => {
return reviewService.isAuthorizedToReview(applicationId, reviewerUserId);
},
},
Mutation: {
login: async (
Expand Down
56 changes: 56 additions & 0 deletions backend/typescript/graphql/resolvers/dashboardResolvers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { auth } from "firebase-admin";
import AppDashboardService from "../../services/implementations/appDashboardService";
import IAppDashboardService from "../../services/interfaces/appDashboardService";
import {
Expand All @@ -11,6 +12,12 @@ const dashboardService: IAppDashboardService = new AppDashboardService();

const dashboardResolvers = {
Query: {
dashboardsByApplicationAuthId: (
_parent: undefined,
{ authId }: { authId: string },
): Promise<ApplicationDashboardDTO[]> => {
return dashboardService.getDashboardsByApplicationAuthId(authId);
},
dashboardById: async (
_parent: undefined,
{ id }: { id: number },
Expand Down Expand Up @@ -44,6 +51,48 @@ const dashboardResolvers = {
},
},
Mutation: {
createApplicationDashboard: async (
_parent: undefined,
{
reviewerEmail,
applicationId,
reviewerAuthId,
passionFSG,
teamPlayer,
desireToLearn,
skill,
skillCategory,
reviwerComments,
recommendedSecondChoice,
reviewComplete
}: {
reviewerEmail: string;
applicationId: number;
reviewerAuthId: string;
passionFSG: number;
teamPlayer: number;
desireToLearn: number;
skill: number;
skillCategory: string;
reviwerComments: string;
recommendedSecondChoice: string;
reviewComplete: boolean;
},
): Promise<ApplicationDashboardDTO> => {
return dashboardService.createApplicationDashboard(
reviewerEmail,
applicationId,
reviewerAuthId,
passionFSG,
teamPlayer,
desireToLearn,
skill,
skillCategory,
reviwerComments,
recommendedSecondChoice,
reviewComplete
);
},
changeRating: async (
_parent: undefined,
{
Expand Down Expand Up @@ -72,6 +121,13 @@ const dashboardResolvers = {
): Promise<Array<number>> => {
return dashboardService.updateBulkApplications(applications);
},
updateApplicationByAuthIdAndApplicationId: async (
_parent: undefined,
{ applicationId, authId, application }: { applicationId: number, authId: string, application: ApplicationDashboardInput },
): Promise<ApplicationDashboardDTO> => {
dashboardService.updateBulkApplications([application])
return dashboardService.updateApplicationByAuthIdAndApplicationId(applicationId, authId, application);
},
modifyFinalComments: async (
_parent: undefined,
{
Expand Down
44 changes: 37 additions & 7 deletions backend/typescript/graphql/types/dashboardType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,32 @@ const dashboardType = gql`
recommendedSecondChoice: String!
reviewerId: Int!
applicationId: Int!
reviewComplete: Boolean
}

input ApplicationDashboardInput {
id: Int!
reviewerEmail: String
passionFSG: Int
teamPlayer: Int
desireToLearn: Int
skill: Int
skillCategory: String
reviewerId: Int
reviewerEmail: String!
passionFSG: Int!
teamPlayer: Int!
desireToLearn: Int!
skill: Int!
skillCategory: String!
reviewerComments: String!
recommendedSecondChoice: String!
reviewerId: Int!
reviewComplete: Boolean
}

input ApplicationDashBoardScoreUpdate {
passionFSG: Int!
teamPlayer: Int!
desireToLearn: Int!
skill: Int!
skillCategory: String!
reviewerComments: String!
recommendedSecondChoice: String!
reviewComplete: Boolean
}

type ApplicationDTO {
Expand Down Expand Up @@ -73,6 +88,7 @@ const dashboardType = gql`
applicationsByRole(firstChoice: String!): [ApplicationDTO]!
dashboardsByApplicationId(applicationId: Int!): [ApplicationDashboardDTO]!
applicationTable(role: String!): [ApplicationDashboardRowDTO]!
dashboardsByApplicationAuthId(authId: String!): [ApplicationDashboardDTO]!
}

extend type Mutation {
Expand All @@ -83,12 +99,26 @@ const dashboardType = gql`
): ApplicationDashboardDTO!
changeSkillCategory(id: Int!, newValue: String!): ApplicationDashboardDTO!
updateApplications(applications: [ApplicationDashboardInput]!): [Int]!
updateApplicationByAuthIdAndApplicationId(authId: String!, applicationId: Int!, application: ApplicationDashBoardScoreUpdate!): ApplicationDashboardDTO
modifyFinalComments(
id: Int!
newComments: String!
newSkillCategory: String!
newRecommendedSecondChoice: String
): ApplicationDashboardDTO!
createApplicationDashboard(
reviewerEmail: String!
applicationId: Int!
reviewerAuthId: String!
passionFSG: Int!
teamPlayer: Int!
desireToLearn: Int!
skill: Int!
skillCategory: String!
reviwerComments: String!
recommendedSecondChoice: String!
reviewComplete: Boolean!
): ApplicationDashboardDTO!
}
`;

Expand Down
9 changes: 9 additions & 0 deletions backend/typescript/graphql/types/reviewType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { gql } from "apollo-server-express";

const reviewType = gql`
extend type Query {
isAuthorizedToReview(applicationId: Int!, reviewerUserId: String!): Boolean!
}
`;

export default reviewType;
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,20 @@ const SEEDED_DATA = [
last_name: "Doe",
email: "[email protected]",
auth_id: "bide",
id: 1,
role: "User",
},
{
first_name: "Jane",
last_name: "Doe",
email: "[email protected]",
auth_id: "none",
id: 2,
role: "Admin",
},
{
first_name: "UW",
last_name: "Blueprint",
email: "[email protected]",
auth_id: "1Z4wyuonu9MhAi4VoAEiTMVj1iT2",
id: 4,
role: "Admin",
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const userEmails = ["[email protected]", "[email protected]"];

const SEEDED_DATA = [
{
id: 1,
applicationId: 1,
reviewerId: 1,
reviewerEmail: userEmails[0],
Expand All @@ -19,9 +18,9 @@ const SEEDED_DATA = [
reviewerComments: "Great job presenting your case study!",
recommendedSecondChoice: "N/A",
skillCategory: "junior",
reviewComplete: false,
},
{
id: 2,
applicationId: 1,
reviewerId: 2,
reviewerEmail: userEmails[1],
Expand All @@ -32,6 +31,7 @@ const SEEDED_DATA = [
reviewerComments: "Very good!",
recommendedSecondChoice: "considered",
skillCategory: "intermediate",
reviewComplete: true,
},
];

Expand All @@ -42,6 +42,7 @@ export const up: Migration = async ({ context: sequelize }) => {
allowNull: false,
primaryKey: true,
unique: true,
autoIncrement: true,
},
applicationId: {
type: DataType.INTEGER,
Expand Down Expand Up @@ -91,6 +92,10 @@ export const up: Migration = async ({ context: sequelize }) => {
type: DataType.ENUM("N/A", "considered", "not considered"),
allowNull: false,
},
reviewComplete: {
type: DataType.BOOLEAN,
allowNull: false,
},
createdAt: DataType.DATE,
updatedAt: DataType.DATE,
});
Expand Down
10 changes: 9 additions & 1 deletion backend/typescript/models/applicationDashboard.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ export default class ApplicationDashboardTable extends Model {
@Column({ type: DataType.STRING })
reviewerEmail!: string;

@Column({ type: DataType.INTEGER, primaryKey: true, unique: true })
@Column({ type: DataType.BOOLEAN })
reviewComplete!: boolean;

@Column({
type: DataType.INTEGER,
primaryKey: true,
unique: true,
autoIncrement: true,
})
id!: number;

@Column({ type: DataType.INTEGER })
Expand Down
Loading