From 83d2776aaa7074af4d23d610dd261726de6270dd Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Tue, 15 Oct 2024 17:44:38 -0400 Subject: [PATCH 1/3] Update SQL and model with expected class size. --- src/models/class.ts | 7 ++++++- src/sql/create_class_table.sql | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/models/class.ts b/src/models/class.ts index 887058d..cd74ea7 100644 --- a/src/models/class.ts +++ b/src/models/class.ts @@ -11,6 +11,7 @@ export class Class extends Model, InferCreationAttributes declare code: string; declare asynchronous: CreationOptional; declare test: CreationOptional; + declare expected_size: CreationOptional; } export function initializeClassModel(sequelize: Sequelize) { @@ -61,7 +62,11 @@ export function initializeClassModel(sequelize: Sequelize) { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: 0 - } + }, + expected_size: { + type: DataTypes.INTEGER.UNSIGNED, + allowNull: false, + }, }, { sequelize, }); diff --git a/src/sql/create_class_table.sql b/src/sql/create_class_table.sql index 3c1a96b..d639b4d 100644 --- a/src/sql/create_class_table.sql +++ b/src/sql/create_class_table.sql @@ -8,6 +8,7 @@ CREATE TABLE Classes ( asynchronous tinyint(1) NOT NULL DEFAULT 0, test tinyint(1) NOT NULL DEFAULT 0, updated datetime DEFAULT NULL, + expected_size int(11) UNSIGNED NOT NULL, PRIMARY KEY(id), INDEX(educator_id), From 28716be8c0698470974fc6aa1fdba6c2a80811ab Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Tue, 15 Oct 2024 17:50:33 -0400 Subject: [PATCH 2/3] Update class creation schema with expected_size. --- src/database.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/database.ts b/src/database.ts index b700fbb..917e024 100644 --- a/src/database.ts +++ b/src/database.ts @@ -311,6 +311,7 @@ export async function signUpStudent(options: SignUpStudentOptions): Promise; From c54272c818af686ff20d310b75bc035a3531cd4f Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 16 Oct 2024 00:53:31 -0400 Subject: [PATCH 3/3] Update tests for updated class schema. --- tests/educators.test.ts | 2 +- tests/students.test.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/educators.test.ts b/tests/educators.test.ts index 1496b00..4c0adc7 100644 --- a/tests/educators.test.ts +++ b/tests/educators.test.ts @@ -7,7 +7,7 @@ import type { Express } from "express"; import { authorize, getTestDatabaseConnection } from "./utils"; import { setupApp } from "../src/app"; -import { Class, Educator, Student, StudentsClasses } from "../src/models"; +import { Educator } from "../src/models"; import { createApp } from "../src/server"; import { v4 } from "uuid"; diff --git a/tests/students.test.ts b/tests/students.test.ts index f2c182b..193de39 100644 --- a/tests/students.test.ts +++ b/tests/students.test.ts @@ -27,11 +27,13 @@ async function setupStudentInClasses() { name: v4(), educator_id: educator.id, code: v4(), + expected_size: 1, }); const class2 = await Class.create({ name: v4(), educator_id: educator.id, code: v4(), + expected_size: 1, }); const student = await Student.create({ email: v4(),