Skip to content

Commit

Permalink
Merge pull request #88 from Carifio24/multiple-responses
Browse files Browse the repository at this point in the history
Store list of MC responses for eclipse mini
  • Loading branch information
Carifio24 authored Oct 4, 2023
2 parents 91658ca + 9a9a57a commit 64ab001
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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

0 comments on commit 64ab001

Please sign in to comment.