Skip to content

Commit

Permalink
Merge pull request #44 from uwblueprint/INTF23-linting
Browse files Browse the repository at this point in the history
[INTF23] Fixes minor issues and lints
  • Loading branch information
HeetShah authored Nov 15, 2023
2 parents 81f24a5 + 3b8a321 commit 2a20497
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 56 deletions.
12 changes: 6 additions & 6 deletions backend/typescript/graphql/resolvers/authResolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CookieOptions, Request, Response } from "express";
// import { CookieOptions } from "express";

import * as firebaseAdmin from "firebase-admin";
import nodemailerConfig from "../../nodemailer.config";
Expand All @@ -19,11 +19,11 @@ const emailService: IEmailService = new EmailService(nodemailerConfig);
const authService: IAuthService = new AuthService(userService, emailService);
const reviewService: IReviewService = new ReviewService();

const cookieOptions: CookieOptions = {
httpOnly: true,
sameSite: process.env.PREVIEW_DEPLOY ? "none" : "strict",
secure: process.env.NODE_ENV === "production",
};
// const cookieOptions: CookieOptions = {
// httpOnly: true,
// sameSite: process.env.PREVIEW_DEPLOY ? "none" : "strict",
// secure: process.env.NODE_ENV === "production",
// };

// Object to pass back when frontend queries a login request
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
7 changes: 3 additions & 4 deletions backend/typescript/graphql/resolvers/dashboardResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ const dashboardResolvers = {
firstChoice,
);
return applications;
},applicationsById: async (
},
applicationsById: async (
_parent: undefined,
{ id }: { id: number },
): Promise<ApplicationDTO> => {
const application = await dashboardService.getApplicationsById(
id,
);
const application = await dashboardService.getApplicationsById(id);
return application;
},
dashboardsByApplicationId: async (
Expand Down
19 changes: 9 additions & 10 deletions backend/typescript/migrations/2023.04.05T17.43.42.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { DataType } from "sequelize-typescript";
// import ApplicationDashboardTable from "../models/applicationDashboard.model";
// import User from "../models/user.model";

import { DataTypes } from "sequelize";
import { Migration } from "../umzug";
import allApplications from "./applicationlist.json";
import { DataTypes } from "sequelize";
import { statusType, secondChoiceStatusType } from "../types";
import { StatusType, SecondChoiceStatusType } from "../types";

const TABLE_NAME = "applicantresponse";

Expand Down Expand Up @@ -36,10 +36,10 @@ const importApplicationData = () => {
status: currApplication.status,
term: currApplication.term,
timesApplied: currApplication.timesApplied,
timestamp: currApplication.timestamp
timestamp: currApplication.timestamp,
};
});

return seededData;
};

Expand Down Expand Up @@ -98,7 +98,7 @@ export const up: Migration = async ({ context: sequelize }) => {
},
resumeUrl: {
type: DataType.STRING(4000),
allowNull: true,
allowNull: true,
},
roleSpecificQuestions: {
type: DataType.ARRAY(DataType.STRING(4000)),
Expand All @@ -113,14 +113,14 @@ export const up: Migration = async ({ context: sequelize }) => {
allowNull: true,
},
status: {
type: DataType.ENUM(...Object.values(statusType)),
type: DataType.ENUM(...Object.values(StatusType)),
allowNull: false,
defaultValue: statusType.PENDING
defaultValue: StatusType.PENDING,
},
secondChoiceStatus: {
type: DataTypes.ENUM(...Object.values(secondChoiceStatusType)),
type: DataTypes.ENUM(...Object.values(SecondChoiceStatusType)),
allowNull: false,
defaultValue: secondChoiceStatusType.NOT_APPLICABLE
defaultValue: SecondChoiceStatusType.NOT_APPLICABLE,
},
term: {
type: DataType.STRING(4000),
Expand All @@ -141,7 +141,6 @@ export const up: Migration = async ({ context: sequelize }) => {
const SEEDED_DATA = importApplicationData();

await sequelize.getQueryInterface().bulkInsert(TABLE_NAME, SEEDED_DATA);

};

export const down: Migration = async ({ context: sequelize }) => {
Expand Down
19 changes: 9 additions & 10 deletions backend/typescript/models/application.model.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint import/no-cycle: 0 */

import { Column, DataType, HasMany, Model, Table } from "sequelize-typescript";
import { DataTypes } from "sequelize";
import ApplicationDashboardTable from "./applicationDashboard.model";
import { DataTypes, Sequelize } from "sequelize";
import { statusType, secondChoiceStatusType } from "../types";

import { StatusType, SecondChoiceStatusType } from "../types";

@Table({ tableName: "applicantresponse" })
export default class Application extends Model {
Expand Down Expand Up @@ -56,17 +55,17 @@ export default class Application extends Model {
@Column({ type: DataType.ARRAY(DataType.STRING) })
shortAnswerQuestions!: string[];

@Column({
type: DataType.ENUM(...Object.values(statusType)),
defaultValue: statusType.PENDING
@Column({
type: DataType.ENUM(...Object.values(StatusType)),
defaultValue: StatusType.PENDING,
})
status!: statusType;
status!: StatusType;

@Column({
type: DataTypes.ENUM(...Object.values(secondChoiceStatusType)),
defaultValue: secondChoiceStatusType.NOT_APPLICABLE
type: DataTypes.ENUM(...Object.values(SecondChoiceStatusType)),
defaultValue: SecondChoiceStatusType.NOT_APPLICABLE,
})
secondChoiceStatus!: secondChoiceStatusType;
secondChoiceStatus!: SecondChoiceStatusType;

@Column({ type: DataType.STRING })
term!: string;
Expand Down
22 changes: 12 additions & 10 deletions backend/typescript/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { sequelize } from "./models";
import schema from "./graphql";
import Application from "./models/application.model";


const CORS_ALLOW_LIST = [
"http://localhost:3000",
"https://uw-blueprint-starter-code.firebaseapp.com",
Expand Down Expand Up @@ -64,16 +63,20 @@ admin.initializeApp({
const db = admin.database();
const ref = db.ref("studentApplications");


app.get("/termApplications", async (req, res) => {
ref.orderByChild("term").equalTo("Fall 2023").once("value", function (snapshot) {
const applications: Application[] = [];
snapshot.forEach((childSnapshot) => {
applications.push(childSnapshot.val());
ref
.orderByChild("term")
.equalTo("Fall 2023")

.once("value", function fn(snapshot) {
const applications: Application[] = [];
snapshot.forEach((childSnapshot) => {
applications.push(childSnapshot.val());
});
res.status(200).json(applications);
});
res.status(200).json(applications);
})});

});

app.get("/applications", async (req, res) => {
try {
const snapshot = await ref.once("value");
Expand All @@ -83,7 +86,6 @@ app.get("/applications", async (req, res) => {
});
res.status(200).json(applications);
} catch (error) {
console.error(error);
res
.status(500)
.send("An error occurred while retrieving the applications.");
Expand Down
20 changes: 11 additions & 9 deletions backend/typescript/services/implementations/appDashboardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AppDashboardService implements IAppDashboardService {
secondChoiceStatus: application.secondChoiceStatus,
term: application.term,
timesApplied: application.timesApplied,
timestamp: application.timestamp
timestamp: application.timestamp,
};
});
} catch (error: unknown) {
Expand All @@ -99,20 +99,22 @@ 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<ApplicationDTO> {
// Takes in an application id and returns an array of applicants with same id
async getApplicationsById(id: number): Promise<ApplicationDTO> {
let applications: Array<Application> | null;
let applicationById: Application |undefined;
let applicationById: Application | undefined;
let applicationByIdDTO: ApplicationDTO;
try {
applications = await Application.findAll();
applicationById = applications.find(application => application.id == id);
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,
academicOrCoop: applicationById.academicOrCoop,
Expand All @@ -134,8 +136,8 @@ async getApplicationsById(id: number): Promise<ApplicationDTO> {
status: applicationById.status,
term: applicationById.term,
timesApplied: applicationById.timesApplied,
timestamp: applicationById.timestamp
};
timestamp: applicationById.timestamp,
};
} catch (error: unknown) {
Logger.error(
`Failed to get applications by id = ${id}. Reason = ${getErrorMessage(
Expand All @@ -144,7 +146,7 @@ async getApplicationsById(id: number): Promise<ApplicationDTO> {
);
throw error;
}
return applicationByIdDTO;
return applicationByIdDTO;
}

async getDashboardsByApplicationId(
Expand Down
12 changes: 5 additions & 7 deletions backend/typescript/types.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
export type Role = "User" | "Admin";


export enum statusType {
export enum StatusType {
ACCEPTED = "accepted",
APPLIED = "applied",
INTERVIEWED = "interviewed",
IN_REVIEW = "in review",
PENDING = "pending",
REJECTED = "rejected"
REJECTED = "rejected",
}

export enum secondChoiceStatusType {
export enum SecondChoiceStatusType {
CONSIDERED = "considered",
NOT_CONSIDERED = "not considered",
NOT_APPLICABLE = "n/a",
RECOMMENDED = "recommended",
IN_REVIEW = "in review",
INTERVIEW = "interview",
NO_INTERVIEW = "no interview"
NO_INTERVIEW = "no interview",
}

export type Token = {
Expand Down Expand Up @@ -68,13 +67,12 @@ export type ApplicationDTO = {
resumeUrl: string;
roleSpecificQuestions: string[];
secondChoiceRole: string;
shortAnswerQuestions: string[]
shortAnswerQuestions: string[];
status: string;
secondChoiceStatus: string;
term: string;
timesApplied: string;
timestamp: bigint;

};

export type ApplicationDashboardRowDTO = {
Expand Down

0 comments on commit 2a20497

Please sign in to comment.