Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { DataTypes } from "sequelize";
import { Migration } from "../umzug";

const TABLE_NAME = "interviewed_applicant_records";

export const up: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().createTable(TABLE_NAME, {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
allowNull: false,
primaryKey: true,
},
applicantRecordId: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
references: {
model: "applicant_records",
key: "id",
},
},
score: {
type: DataTypes.INTEGER,
allowNull: true,
},
interviewJson: {
type: DataTypes.JSONB,
allowNull: true,
},
status: {
type: DataTypes.STRING,
allowNull: false,
},
interviewNotesId: {
type: DataTypes.UUID,
allowNull: true,
references: {
model: "firebase_files",
key: "id",
},
},
schedulingLink: {
type: DataTypes.STRING,
allowNull: true,
},
interviewDate: {
type: DataTypes.DATE,
allowNull: true,
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
});
};

export const down: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().dropTable(TABLE_NAME);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { DataType } from "sequelize-typescript";
import { Migration } from "../umzug";
import { interviewConflictOptions } from "../types";

const TABLE_NAME = "interview_delegations";

export const up: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().createTable(TABLE_NAME, {
interviewedApplicantRecordId: {
type: DataType.UUID,
allowNull: false,
references: {
model: "interviewed_applicant_records",
key: "id",
},
primaryKey: true,
},
interviewerId: {
type: DataType.INTEGER,
allowNull: false,
references: {
model: "users",
key: "id",
},
primaryKey: true,
},
interviewHasConflict: {
type: DataType.ENUM(...interviewConflictOptions),
allowNull: true,
defaultValue: null,
},
});
};

export const down: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().dropTable(TABLE_NAME);
};
44 changes: 44 additions & 0 deletions backend/typescript/models/interviewDelegation.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint import/no-cycle: 0 */

import {
BelongsTo,
Column,
DataType,
ForeignKey,
Model,
Table,
} from "sequelize-typescript";
import { NonAttribute } from "sequelize";
import { InterviewConflict, interviewConflictOptions } from "../types";
import User from "./user.model";
import InterviewedApplicantRecord from "./interviewedApplicantRecord.model";

@Table({ tableName: "interview_delegations" })
export default class InterviewDelegation extends Model {
@ForeignKey(() => InterviewedApplicantRecord)
@Column({ type: DataType.UUID, primaryKey: true })
interviewedApplicantRecordId!: string;

@ForeignKey(() => User)
@Column({ type: DataType.INTEGER, primaryKey: true })
interviewerId!: number;

@Column({
type: DataType.ENUM(...interviewConflictOptions),
allowNull: true,
defaultValue: null,
})
interviewHasConflict?: InterviewConflict | null;

@BelongsTo(() => InterviewedApplicantRecord, {
foreignKey: "interviewedApplicantRecordId",
targetKey: "id",
})
interviewedApplicantRecord?: NonAttribute<InterviewedApplicantRecord>;

@BelongsTo(() => User, {
foreignKey: "interviewerId",
targetKey: "id",
})
interviewer?: NonAttribute<User>;
}
79 changes: 79 additions & 0 deletions backend/typescript/models/interviewedApplicantRecord.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {
Column,
DataType,
ForeignKey,
Model,
Table,
} from "sequelize-typescript";
import { Interview, InterviewStatus } from "../types";
import ApplicantRecord from "./applicantRecord.model";
import File from "./file.model";

@Table({ tableName: "interviewed_applicant_records" })
export default class InterviewedApplicantRecord extends Model {
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4,
primaryKey: true,
})
id!: string;

@ForeignKey(() => ApplicantRecord)
@Column({
type: DataType.STRING,
allowNull: false,
unique: true,
})
applicantRecordId!: string;

@Column({
type: DataType.INTEGER,
allowNull: true,
})
score!: number | null;

@Column({
type: DataType.JSONB,
allowNull: true,
})
interviewJson!: Interview | null;

@Column({
type: DataType.STRING,
allowNull: false,
})
status!: InterviewStatus;

@ForeignKey(() => File)
@Column({
type: DataType.UUID,
allowNull: true,
})
interviewNotesId!: string | null;

@Column({
type: DataType.STRING,
allowNull: true,
})
schedulingLink!: string | null;

@Column({
type: DataType.DATE,
allowNull: true,
})
interviewDate!: Date | null;

@Column({
type: DataType.DATE,
allowNull: false,
defaultValue: DataType.NOW,
})
createdAt!: Date;

@Column({
type: DataType.DATE,
allowNull: false,
defaultValue: DataType.NOW,
})
updatedAt!: Date;
}
36 changes: 36 additions & 0 deletions backend/typescript/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ export type ApplicationStatus =

export type SkillCategory = "Junior" | "Intermediate" | "Senior";

export type Interview = {
passionFSG?: number;
teamPlayer?: number;
desireToLearn?: number;
skill?: number;
skillCategory?: SkillCategory;
comments?: string;
};

export type InterviewStatus = "NeedsReview" | "InProgress" | "Complete";

export type ApplicantRecordExtraInfo = {
adminReview?: string;
};
Expand Down Expand Up @@ -222,6 +233,17 @@ export type DeleteReviewedApplicantRecordDTO = {
reviewerId: number;
};

export type InterviewedApplicantRecordDTO = {
id: string;
applicantRecordId: string;
score: number | null;
interviewJson: Interview | null;
status: InterviewStatus;
interviewNotesId: string | null;
schedulingLink: string | null;
interviewDate: Date | null;
};

export type ReviewDetails = {
reviewerFirstName: string;
reviewerLastName: string;
Expand Down Expand Up @@ -274,3 +296,17 @@ export type CreateFirebaseFileDTO = Omit<
FirebaseFileDTO,
"id" | "createdAt" | "updatedAt"
>;

export const interviewConflictOptions = [
"APPLICANT_CONFLICT", // Conflict of interest with the applicant
"APPLICANT_NO_RESPONSE", // Applicant did not respond to the interview request
"PARTNER_NO_RESPONSE", // Partner did not respond to the interview request
"CANNOT_ATTEND", // Cannot make interview
] as const;
export type InterviewConflict = (typeof interviewConflictOptions)[number];

export type InterviewDelegationDTO = {
interviewedApplicantRecordId: string;
interviewerId: number;
interviewHasConflict?: InterviewConflict | null;
};
Loading