Skip to content

Commit

Permalink
adds secondChoiceStatusType and ENUM
Browse files Browse the repository at this point in the history
  • Loading branch information
HeetShah committed Nov 2, 2023
1 parent 6f42119 commit 45c52fe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
13 changes: 8 additions & 5 deletions backend/typescript/migrations/2023.04.05T17.43.42.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { DataType } from "sequelize-typescript";

import { Migration } from "../umzug";
import allApplications from "./applicationlist.json";
import { simpleEntityRequestDtoValidator } from "../middlewares/validators/simpleEntityValidators";
import { DataTypes } from "sequelize";
import { secondChoiceStatusType } from "../types";

const TABLE_NAME = "applicantresponse";

Expand Down Expand Up @@ -97,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 @@ -116,9 +117,9 @@ export const up: Migration = async ({ context: sequelize }) => {
allowNull: true,
},
secondChoiceStatus: {
type: DataType.ENUM("considered", "not considered", "n/a", "interview", "recommended", "in review", "interview", "no interview"),
defaultValue: "n/a",
allowNull: true,
type: DataTypes.ENUM(...Object.values(secondChoiceStatusType)),
allowNull: false,
defaultValue: secondChoiceStatusType.NOT_APPLICABLE
},
term: {
type: DataType.STRING(4000),
Expand All @@ -137,7 +138,9 @@ 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
9 changes: 6 additions & 3 deletions backend/typescript/models/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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


@Table({ tableName: "applicantresponse" })
export default class Application extends Model {
Expand Down Expand Up @@ -57,10 +60,10 @@ export default class Application extends Model {
status!: string;

@Column({
type: DataType.ENUM("considered", "not considered", "n/a", "recommended", "in review", "interview", "no interview"),
defaultValue: "n/a"
type: DataTypes.ENUM(...Object.values(secondChoiceStatusType)),
defaultValue: secondChoiceStatusType.NOT_APPLICABLE
})
secondChoiceStatus!: string;
secondChoiceStatus!: secondChoiceStatusType;

@Column({ type: DataType.STRING })
term!: string;
Expand Down
10 changes: 10 additions & 0 deletions backend/typescript/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export type Role = "User" | "Admin";

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"
}

export type Token = {
accessToken: string;
refreshToken: string;
Expand Down

0 comments on commit 45c52fe

Please sign in to comment.