From ea18873c00185e43d0d2617358a9c025e1956b8a Mon Sep 17 00:00:00 2001 From: cycxllin Date: Sat, 2 Nov 2024 13:27:56 -0600 Subject: [PATCH 1/2] Added cluster attribute (the begining of the coordinate string) to the Cluster model for easier searching --- search-service/controllers/Upload.js | 1 + search-service/models/Cluster.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/search-service/controllers/Upload.js b/search-service/controllers/Upload.js index 38b3ad2..a9be467 100644 --- a/search-service/controllers/Upload.js +++ b/search-service/controllers/Upload.js @@ -35,6 +35,7 @@ const uploadSingleJson = async (jsonOld, numtoPrint = 0, printClusters = true) = const newCluster = await Cluster.create({ coordinate: jsonOld.coordinate, + cluster: jsonOld.cluster, gameVersion: parseInt(jsonOld["gameVersion"]), vanilla: vanilla, spacedOut: spacedOut, diff --git a/search-service/models/Cluster.js b/search-service/models/Cluster.js index 4507ed7..1174145 100644 --- a/search-service/models/Cluster.js +++ b/search-service/models/Cluster.js @@ -8,13 +8,18 @@ const Cluster = sequelize.define('Cluster', { primaryKey: true, type: DataTypes.STRING, allowNull: false - //TODO add validation + //TODO: add validation + }, + + cluster: { + type: DataTypes.STRING, + allowNull: false }, gameVersion: { type: DataTypes.STRING, allowNull: false - //TODO add validation + //TODO: add validation }, vanilla: { From eebf86730acd2ae8adad948e5f005d2255147633 Mon Sep 17 00:00:00 2001 From: cycxllin Date: Sat, 2 Nov 2024 15:29:04 -0600 Subject: [PATCH 2/2] Changed to set associations after syncing tables. --- search-service/controllers/Upload.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/search-service/controllers/Upload.js b/search-service/controllers/Upload.js index a9be467..01b417e 100644 --- a/search-service/controllers/Upload.js +++ b/search-service/controllers/Upload.js @@ -163,8 +163,7 @@ const initializeDatabase = async () => { await TotalGeyserOutput.sync({ alter: true }); */ console.log("Initializing database...") - setAssociations() - console.log("Set associations. Syncing...") + console.log("Syncing...") //await sequelize.sync({force:true}); await Cluster.sync({ force: true }); console.log('----------------cluster created------------'); @@ -174,8 +173,10 @@ const initializeDatabase = async () => { console.log('----------------asteroid created------------'); await TotalGeyserOutput.sync({ force: true }); console.log('----------------TotalGeyserOutput created------------'); - console.log('All tables created successfully!'); + setAssociations(); + console.log("Set associations.") + database_initialized = true } catch (error) { console.error('Error creating tables: ', error);