Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store list of MC responses for eclipse mini #88

Merged
merged 2 commits into from
Oct 4, 2023
Merged
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
4 changes: 2 additions & 2 deletions src/stories/minids/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/stories/minids/models/eclipse_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Sequelize, DataTypes, Model, InferAttributes, InferCreationAttributes,
export class EclipseMiniResponse extends Model<InferAttributes<EclipseMiniResponse>, InferCreationAttributes<EclipseMiniResponse>> {
declare id: CreationOptional<number>;
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][];
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion src/stories/minids/sql/create_eclipse_response_table.sql
Original file line number Diff line number Diff line change
@@ -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,
mc_responses JSON DEFAULT NULL,
preset_locations JSON NOT NULL,
preset_locations_count INT NOT NULL,
user_selected_locations JSON NOT NULL,
Expand Down