From c3cb5d166856f7f5fe6f1a18010d75c992b8e02a Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 4 Oct 2023 17:51:28 -0400 Subject: [PATCH 1/2] Now store a list of eclipse MC responses. --- src/stories/minids/database.ts | 4 ++-- src/stories/minids/models/eclipse_response.ts | 6 +++--- src/stories/minids/sql/create_eclipse_response_table.sql | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/stories/minids/database.ts b/src/stories/minids/database.ts index 498213e..e35d109 100644 --- a/src/stories/minids/database.ts +++ b/src/stories/minids/database.ts @@ -12,7 +12,7 @@ initializeModels(cosmicdsDB); export interface EclipseMiniData { user_uuid: string; - response: string; + mc_responses: string[]; preset_locations: string[], user_selected_locations: [number, number][], timestamp: Date @@ -22,7 +22,7 @@ export interface EclipseMiniData { export function isValidEclipseMiniData(data: any): data is EclipseMiniData { return typeof data.user_uuid === "string" && - (!data.response || typeof data.response === "string") && + (!data.mc_responses || isStringArray(data.mc_responses)) && isStringArray(data.preset_locations) && isArrayThatSatisfies(data.user_selected_locations, (arr) => { return arr.every(x => isNumberArray(x) && x.length === 2); diff --git a/src/stories/minids/models/eclipse_response.ts b/src/stories/minids/models/eclipse_response.ts index 58e49cb..64c4e02 100644 --- a/src/stories/minids/models/eclipse_response.ts +++ b/src/stories/minids/models/eclipse_response.ts @@ -3,7 +3,7 @@ import { Sequelize, DataTypes, Model, InferAttributes, InferCreationAttributes, export class EclipseMiniResponse extends Model, InferCreationAttributes> { declare id: CreationOptional; declare user_uuid: string; - declare response: string; + declare mc_responses: string[]; declare preset_locations: string[]; declare preset_locations_count: number; declare user_selected_locations: [number, number][]; @@ -24,8 +24,8 @@ export function initializeEclipseMiniResponseModel(sequelize: Sequelize) { unique: true, allowNull: false }, - response: { - type: DataTypes.CHAR, + mc_responses: { + type: DataTypes.JSON, defaultValue: null }, preset_locations: { diff --git a/src/stories/minids/sql/create_eclipse_response_table.sql b/src/stories/minids/sql/create_eclipse_response_table.sql index f1f1a40..85dd835 100644 --- a/src/stories/minids/sql/create_eclipse_response_table.sql +++ b/src/stories/minids/sql/create_eclipse_response_table.sql @@ -1,7 +1,7 @@ CREATE TABLE EclipseMiniResponses ( id int(11) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, user_uuid varchar(36) NOT NULL UNIQUE, - response char(1) DEFAULT NULL, + responses JSON DEFAULT NULL, preset_locations JSON NOT NULL, preset_locations_count INT NOT NULL, user_selected_locations JSON NOT NULL, From 9a9a57a68d7d359bd2918ea89710917c4bd16118 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 4 Oct 2023 17:53:35 -0400 Subject: [PATCH 2/2] Fix typo in SQL definition. --- src/stories/minids/sql/create_eclipse_response_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stories/minids/sql/create_eclipse_response_table.sql b/src/stories/minids/sql/create_eclipse_response_table.sql index 85dd835..dfbb9dd 100644 --- a/src/stories/minids/sql/create_eclipse_response_table.sql +++ b/src/stories/minids/sql/create_eclipse_response_table.sql @@ -1,7 +1,7 @@ CREATE TABLE EclipseMiniResponses ( id int(11) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, user_uuid varchar(36) NOT NULL UNIQUE, - responses JSON DEFAULT NULL, + mc_responses JSON DEFAULT NULL, preset_locations JSON NOT NULL, preset_locations_count INT NOT NULL, user_selected_locations JSON NOT NULL,