From 5e06a7f81299301521f9a94797f472a508f40a67 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 23 Aug 2021 06:52:57 -0500 Subject: [PATCH 01/14] Database changes and trims --- ngsplanner_patch.sql | 14 ++++++ ngsplanner_schema.sql | 26 +++++------ ngsplanner_seed.sql | 10 ++--- server.js | 102 ++++++++++++++++++++++++++++++++++++++---- 4 files changed, 126 insertions(+), 26 deletions(-) diff --git a/ngsplanner_patch.sql b/ngsplanner_patch.sql index b557a1c..5316e3f 100644 --- a/ngsplanner_patch.sql +++ b/ngsplanner_patch.sql @@ -13,3 +13,17 @@ CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"da ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); alter table skill_tree_data add column halflineheight int; CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text); +alter table class_skill_data alter column damage_taken set data type text; +alter table class_skill_data alter column pa_potency set data type text; +alter table class_skill_data alter column conditional_buff set data type text; +alter table class_skill_data alter column pp_recovery set data type text; +alter table class_skill_data alter column property set data type text; +alter table class_skill_data alter column all_damage_buff set data type text; +alter table class_skill_data alter column active_pp_recovery set data type text; +alter table class_skill_data alter column status_ailment_accum set data type text; +alter table class_skill_data alter column status_ailment_duration set data type text; +alter table class_skill_data alter column pp_consumption set data type text; +alter table class_skill_data alter column max_hp_decrease set data type text; +alter table class_skill_data alter column natural_pp_recovery set data type text; +alter table class_skill_data alter column pb_gauge_fortification set data type text; +alter table site_data rename column field to name; \ No newline at end of file diff --git a/ngsplanner_schema.sql b/ngsplanner_schema.sql index 37ecf75..d41cfa5 100644 --- a/ngsplanner_schema.sql +++ b/ngsplanner_schema.sql @@ -117,7 +117,7 @@ CREATE TABLE "armor" ( "crit_dmg" float, "pp_cost_reduction" float, "active_pp_recovery" float, - "natural_pp_recovery" float, + "natural_pp_recovery" text, "dmg_res" float, "all_down_res" float, "burn_res" float, @@ -247,20 +247,20 @@ CREATE TABLE "class_skill_data" ( "effect" text, "duration" int, "cooldown" int, - "damage_taken" float, - "pa_potency" float, + "damage_taken" text, + "pa_potency" text, "conditional_buff" boolean, - "pp_recovery" float, + "pp_recovery" text, "property" text, - "all_damage_buff" float, - "active_pp_recovery" float, - "status_ailment_accum" float, - "status_ailment_duration" float, - "pp_consumption" float, - "max_hp_decrease" float, - "natural_pp_recovery" float, + "all_damage_buff" text, + "active_pp_recovery" text, + "status_ailment_accum" text, + "status_ailment_duration" text, + "pp_consumption" text, + "max_hp_decrease" text, + "natural_pp_recovery" text, "added_pp" int, - "pb_gauge_fortification" float + "pb_gauge_fortification" text ); CREATE TABLE "database_audit" ( @@ -322,7 +322,7 @@ CREATE TABLE "skill_tree_data" ( CREATE TABLE "site_data" ( "id" SERIAL UNIQUE PRIMARY KEY, - "field" text, + "name" text, "data" text ); diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 4dba741..593d865 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -268,15 +268,15 @@ insert into class_skill(name,class_id,icon,description) values('Assault Charge Advent',(SELECT id from class WHERE name='Gunner' limit 1),'','This is '); insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification) - values('Hunter Physique Lv.1',(SELECT id from class_skill WHERE name='Hunter Physique' limit 1),'',1,'Effect Name',20,15,0.7,1,false,0.5,'',0,0,0,0,0,0,0,0,0); + values('Hunter Physique Lv.1',(SELECT id from class_skill WHERE name='Hunter Physique' limit 1),'',1,'Effect Name',20,15,'0.7','1',false,'0.5','','0','0','0','0','0','0','0',0,'0'); insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification) - values('War Cry Lv.1',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',1,'Effect Name',14,10,0.5,1.1,false,0.8,'',0,0,0,0.6,0,0,0,0,0); + values('War Cry Lv.1',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',1,'Effect Name',14,10,0.5,'1.1','0.8',false,'0.6','','0','0','0','0','0','0','0',0,'0'); insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification) - values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,0.8,1.0,false,0.7,'',0,0,0,0.9,0,0,0,0,0); + values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,'0.8','1',false,'0.5','','0','0','0','0','0','0','0',0,'0'); insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification) - values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,1.0,1.1,false,0.8,'',0,0,0,0,0,0,0.6,0,0); + values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,'1.8','1',false,'0.5','','0','0','0','0','0','0','0',0,'1.6'); insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,halflineheight) values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10,60); -insert into site_data(field,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.'); \ No newline at end of file +insert into site_data(name,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.'); \ No newline at end of file diff --git a/server.js b/server.js index 6cb7fcf..fc363fe 100644 --- a/server.js +++ b/server.js @@ -229,7 +229,7 @@ const ENDPOINTDATA=[ }, { endpoint:"site_data", - requiredfields:["field","data"], + requiredfields:["name","data"], optionalfields:[], excludedfields:[] //Fields to not output in GET. } @@ -472,10 +472,14 @@ function CreateDynamicEndpoints() { var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) var requiresInsert=true if (endpoint.requiredfields.includes("name")) { + /*console.log(['update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ + if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ + if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]])*/ await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]) + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -492,7 +496,7 @@ function CreateDynamicEndpoints() { db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return "$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field])) + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -521,8 +525,10 @@ function CreateDynamicEndpoints() { if (endpoint.requiredfields.includes("name")) { await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]) + if (Number.isNaN(Number(req.body[field]))) { + console.log(field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"); + return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -539,7 +545,7 @@ function CreateDynamicEndpoints() { db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return "$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field])) + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -551,11 +557,19 @@ function CreateDynamicEndpoints() { res.status(500).send("Could not authenticate!") } }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) }) } else { res.status(500).send("Could not authenticate!") } }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) }) app.patch(PREFIX+"/"+endpoint.endpoint,(req,res)=>{ @@ -651,7 +665,63 @@ function CreateDynamicEndpoints() { var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) var requiresInsert=true if (endpoint.requiredfields.includes("name")) { - await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]) + /*console.log(['update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ + if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ + if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]])*/ + await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ + if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ + if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) + .then((data)=>{ + if (data.rows.length===0) { + requiresInsert=true + } else { + requiresInsert=false + res.status(200).json(data.rows) + } + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + } + if (requiresInsert) { + db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ + if (!field.includes("_id")) {return "$"+(i+1)}else{ + if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} + }}).join(",")+") returning *",all_filled_fields.map((field)=typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) + .then((data)=>{ + res.status(200).json(data.rows) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + }app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{ + db4.query('select * from password where password=$1',[req.body.pass]) + .then(async(data)=>{ + if (data.rows.length>0) { + var allExist=true + endpoint.requiredfields.forEach((field)=>{ + if (!(field in req.body)) { + allExist=false; + } + }) + if (!allExist) { + res.status(300).send("Required fields are: "+endpoint.requiredfields.filter((field)=>!(field in req.body)).join(',')) + return + } + + var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields] + //console.log(combinedfields) + var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) + var requiresInsert=true + if (endpoint.requiredfields.includes("name")) { + await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ + if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ + if (Number.isNaN(Number(req.body[field]))) { + console.log(field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"); + return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -665,7 +735,10 @@ function CreateDynamicEndpoints() { }) } if (requiresInsert) { - db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field])) + db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ + if (!field.includes("_id")) {return "$"+(i+1)}else{ + if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -677,6 +750,19 @@ function CreateDynamicEndpoints() { res.status(500).send("Could not authenticate!") } }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + }) + } else { + res.status(500).send("Could not authenticate!") + } + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) }) app.patch(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{ From 2afbfaf58f5318932106dacfc6f82e1843d44c40 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 23 Aug 2021 07:03:16 -0500 Subject: [PATCH 02/14] WE are back in business --- server.js | 282 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 171 insertions(+), 111 deletions(-) diff --git a/server.js b/server.js index 04aecc8..0c60c42 100644 --- a/server.js +++ b/server.js @@ -74,11 +74,6 @@ new Pool({ port: 5432, }) - -app.get('/',async(req,res)=>{ - res.status(200).send('BUN is love, BUN is life.') -}) - const PREFIX="" const ENDPOINTDATA=[ @@ -271,8 +266,52 @@ for (var test of ["","/test"]) { }) .then((data)=>{ res.status(200).json(data.rows) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + }) + + app.post(PREFIX+test+"/databases/restorefrombackup",(req,res)=>{ + if (req.body.database) { + db4.query('select * from password where password=$1',[req.body.pass]) + .then((data)=>{ + if (data.rows.length>0) { + return db3.query('select * from pg_database where datname=$1',[req.body.database]) + } else { + var msg="Could not authenticate!";res.status(500).send(msg);throw msg + } + }) + .then((data)=>{ + if (data.rows.length>0) { + db.end(()=>{}) + return db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\'') + } else { + var msg="Could not find requested database "+req.body.database;res.status(500).send(msg);throw msg + } + }) + .then(()=>{ + return db3.query('drop database ngsplanner') + }) + .then(()=>{ + return db3.query('create database ngsplanner with template '+req.body.database) + }) + .then(()=>{ + db = new Pool({ + user: 'postgres', + password: '', + host: 'postgres', + database: 'ngsplanner', + port: 5432, + }) + res.status(200).send("Done!") + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) } else { - res.status(204).send("No data") + res.status(500).send("Invalid data!") } }) app.post(PREFIX+test+"/databases/testtolive",(req,res)=>{ @@ -433,14 +472,10 @@ function CreateDynamicEndpoints() { var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) var requiresInsert=true if (endpoint.requiredfields.includes("name")) { - /*console.log(['update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ - if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]])*/ await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -457,7 +492,7 @@ function CreateDynamicEndpoints() { db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return "$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -486,10 +521,8 @@ function CreateDynamicEndpoints() { if (endpoint.requiredfields.includes("name")) { await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) { - console.log(field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"); - return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) + if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -506,7 +539,7 @@ function CreateDynamicEndpoints() { db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return "$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -518,19 +551,11 @@ function CreateDynamicEndpoints() { res.status(500).send("Could not authenticate!") } }) - .catch((err)=>{ - console.log(err.message) - res.status(500).send(err.message) - }) }) } else { res.status(500).send("Could not authenticate!") } }) - .catch((err)=>{ - console.log(err.message) - res.status(500).send(err.message) - }) }) app.patch(PREFIX+"/"+endpoint.endpoint,(req,res)=>{ @@ -542,7 +567,7 @@ function CreateDynamicEndpoints() { //console.log(combinedfields) var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) - return db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id]) + return db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id]) } else { var msg="Could not authenticate!";res.status(500).send(msg);throw msg } @@ -626,63 +651,7 @@ function CreateDynamicEndpoints() { var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) var requiresInsert=true if (endpoint.requiredfields.includes("name")) { - /*console.log(['update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ - if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]])*/ - await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ - if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) - .then((data)=>{ - if (data.rows.length===0) { - requiresInsert=true - } else { - requiresInsert=false - res.status(200).json(data.rows) - } - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) - } - if (requiresInsert) { - db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ - if (!field.includes("_id")) {return "$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) - .then((data)=>{ - res.status(200).json(data.rows) - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) - }app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{ - db4.query('select * from password where password=$1',[req.body.pass]) - .then(async(data)=>{ - if (data.rows.length>0) { - var allExist=true - endpoint.requiredfields.forEach((field)=>{ - if (!(field in req.body)) { - allExist=false; - } - }) - if (!allExist) { - res.status(300).send("Required fields are: "+endpoint.requiredfields.filter((field)=>!(field in req.body)).join(',')) - return - } - - var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields] - //console.log(combinedfields) - var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) - var requiresInsert=true - if (endpoint.requiredfields.includes("name")) { - await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ - if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) { - console.log(field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"); - return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field]),req.body["name"]]) + await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -696,10 +665,7 @@ function CreateDynamicEndpoints() { }) } if (requiresInsert) { - db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ - if (!field.includes("_id")) {return "$"+(i+1)}else{ - if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field] === 'string'?req.body[field].trim():req.body[field])) + db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -711,19 +677,6 @@ function CreateDynamicEndpoints() { res.status(500).send("Could not authenticate!") } }) - .catch((err)=>{ - console.log(err.message) - res.status(500).send(err.message) - }) - }) - } else { - res.status(500).send("Could not authenticate!") - } - }) - .catch((err)=>{ - console.log(err.message) - res.status(500).send(err.message) - }) }) app.patch(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{ @@ -735,7 +688,7 @@ function CreateDynamicEndpoints() { //console.log(combinedfields) var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) - return db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id]) + return db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id]) } else { var msg="Could not authenticate!";res.status(500).send(msg);throw msg } @@ -781,37 +734,144 @@ function CleanUp(arr,vals){ }) return arrVal }) +} + +app.get(PREFIX+'/data',async(req,res)=>{ + var finalresult = {} + var promises = [] + for (var endpoint of ENDPOINTDATA) { + if (endpoint.requiredfields.includes("name")) { + await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) + }) + } else { + await db.query('select * from '+endpoint.endpoint+" order by id desc") + .then((data)=>{ + finalresult[endpoint.endpoint]=data.rows + }) + } + } + res.status(200).json(finalresult) }) -app.get('/lastUpdate',(req,res)=>{ - db.query("select * from site_data limit 1") +app.get(PREFIX+'/test/data',async(req,res)=>{ + var finalresult = {} + var promises = [] + for (var endpoint of ENDPOINTDATA) { + if (endpoint.requiredfields.includes("name")) { + await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) + }) + } else { + await db2.query('select * from '+endpoint.endpoint+" order by id desc") + .then((data)=>{ + finalresult[endpoint.endpoint]=data.rows + }) + } + } + res.status(200).json(finalresult) +}) + +app.get(PREFIX+'/dataid',async(req,res)=>{ + var finalresult = {} + var promises = [] + for (var endpoint of ENDPOINTDATA) { + await db.query('select * from '+endpoint.endpoint+' order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) + }) + } + res.status(200).json(finalresult) +}) + +app.get(PREFIX+'/test/dataid',async(req,res)=>{ + var finalresult = {} + var promises = [] + for (var endpoint of ENDPOINTDATA) { + await db2.query('select * from '+endpoint.endpoint+' order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) + }) + } + res.status(200).json(finalresult) +}) + +app.post(PREFIX+"/validUser",(req,res)=>{ + //console.log(sh.SecretHash("098f6bcd4621d373cade4e832627b4f6")) + db.query('select * from users where username=$1 and password_hash=$2 limit 1',[req.body.username,sh.SecretHash(req.body.password)]) .then((data)=>{ - res.status(200).json(data.rows) + if (data.rows.length>0) { + res.status(200).json({verified:true}) + } else { + res.status(200).json({verified:false}) + } }) .catch((err)=>{ res.status(500).send(err.message) }) }) -app.post("/updateItem",(req,res)=>{ - db.query("update crafting_list set obtained=$1 where id=$2",[req.body.obtained,req.body.id]) +app.post(PREFIX+"/saveskilltree",(req,res)=>{ + db4.query('select * from password where password=$1',[req.body.pass]) + .then((data)=>{ + if (data.rows.length>0) { + return db.query('select * from skill_tree_data where class_id=$1 limit 1',[req.body.class_id]) + } else { + var msg="Could not authenticate!";res.status(500).send(msg);throw msg + } + }) .then((data)=>{ - return db.query("update site_data set last_modified=$1",[req.body.last_modified]) + if (data.rows.length>0) { + return db.query('update skill_tree_data set data=$1,skill_data=$2,line_color=$3,line_width=$4,gridsizex=$5,gridsizey=$6,gridpaddingx=$7,gridpaddingy=$8,halflineheight=$9 where class_id=$10', + [req.body.data,req.body.skill_data,req.body.line_color,req.body.line_width,req.body.gridsizex,req.body.gridsizey,req.body.gridpaddingx,req.body.gridpaddingy,req.body.halflineheight,req.body.class_id]) + } else { + return db.query('insert into skill_tree_data(data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,class_id,halflineheight) values($1,$2,$3,$4,$5,$6,$7,$8,$10,$9)', + [req.body.data,req.body.skill_data,req.body.line_color,req.body.line_width,req.body.gridsizex,req.body.gridsizey,req.body.gridpaddingx,req.body.gridpaddingy,req.body.halflineheight,req.body.class_id]) + } }) .then((data)=>{ - res.status(200).send("Yay!") + res.status(200).send("OK!") }) .catch((err)=>{ res.status(500).send(err.message) }) }) -app.post('/setItem',(req,res)=>{ - db.query('insert into crafting_list(itemid,name,obtained,required,icon) values($1,$2,$3,$4,$5)',[req.body.itemid,req.body.name,req.body.obtained,req.body.required,req.body.icon]) +app.post(PREFIX+"/test/saveskilltree",(req,res)=>{ + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ - res.status(200).send("Yay!") + if (data.rows.length>0) { + return db2.query('select * from skill_tree_data where class_id=$1 limit 1',[req.body.class_id]) + } else { + var msg="Could not authenticate!";res.status(500).send(msg);throw msg + } + }) + .then((data)=>{ + if (data.rows.length>0) { + return db2.query('update skill_tree_data set data=$1,skill_data=$2,line_color=$3,line_width=$4,gridsizex=$5,gridsizey=$6,gridpaddingx=$7,gridpaddingy=$8,halflineheight=$9 where class_id=$10', + [req.body.data,req.body.skill_data,req.body.line_color,req.body.line_width,req.body.gridsizex,req.body.gridsizey,req.body.gridpaddingx,req.body.gridpaddingy,req.body.halflineheight,req.body.class_id]) + } else { + return db2.query('insert into skill_tree_data(data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,class_id,halflineheight) values($1,$2,$3,$4,$5,$6,$7,$8,$10,$9)', + [req.body.data,req.body.skill_data,req.body.line_color,req.body.line_width,req.body.gridsizex,req.body.gridsizey,req.body.gridpaddingx,req.body.gridpaddingy,req.body.halflineheight,req.body.class_id]) + } + }) + .then((data)=>{ + res.status(200).send("OK!") }) .catch((err)=>{ res.status(500).send(err.message) }) }) + +//Generates our table schema: +ENDPOINTDATA.forEach((endpoint)=>{ + console.log(endpoint.endpoint+":\n\t"+endpoint.requiredfields.join('\t')+(endpoint.optionalfields.length>0?"\t":"")+endpoint.optionalfields.join("\t")) +}) + +CreateDynamicEndpoints() \ No newline at end of file From 2b40a7e159bdbcdad94fbe555d146b92795d5c8e Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Tue, 24 Aug 2021 04:21:33 +0000 Subject: [PATCH 03/14] Update server test with latest modifications. --- server_test.js | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/server_test.js b/server_test.js index affb8c3..1117d03 100644 --- a/server_test.js +++ b/server_test.js @@ -184,7 +184,7 @@ const ENDPOINTDATA=[ }, { endpoint:"site_data", - requiredfields:["field","data"], + requiredfields:["name","data"], optionalfields:[], excludedfields:[] //Fields to not output in GET. } @@ -198,7 +198,7 @@ var lockedTime=new Date().getTime()-LOCKOUTTIME //Starts unlocked for (var test of ["","/test"]) { app.post(PREFIX+test+"/passwordcheck",(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { res.status(200).json({verified:true}) @@ -211,7 +211,7 @@ for (var test of ["","/test"]) { }) }) app.get(PREFIX+test+"/databases",(req,res)=>{ - db.query('select * from password where password=$1',[req.query.pass]) + db4.query('select * from password where password=$1',[req.query.pass]) .then((data)=>{ if (data.rows.length>0) { return db.query('select * from pg_database where datname like \'ngsplanner%\' order by datname desc limit 100') @@ -229,7 +229,7 @@ for (var test of ["","/test"]) { app.post(PREFIX+test+"/databases/restorefrombackup",(req,res)=>{ if (req.body.database) { - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { return db3.query('select * from pg_database where datname=$1',[req.body.database]) @@ -270,7 +270,7 @@ for (var test of ["","/test"]) { } }) app.post(PREFIX+test+"/databases/testtolive",(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { db.end(()=>{}) @@ -310,7 +310,7 @@ for (var test of ["","/test"]) { }) app.post(PREFIX+test+"/databases/livetotest",(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { db.end(()=>{}) @@ -350,7 +350,7 @@ for (var test of ["","/test"]) { app.post(PREFIX+test+"/databases/backup",(req,res)=>{ var date = new Date() - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { db.end(()=>{}) @@ -381,7 +381,7 @@ for (var test of ["","/test"]) { function CreateDynamicEndpoints() { ENDPOINTDATA.forEach((endpoint)=>{ app.get(PREFIX+"/"+endpoint.endpoint,(req,res)=>{ - db.query('select * from password where password=$1',[req.query.pass]) + db4.query('select * from password where password=$1',[req.query.pass]) .then((data)=>{ if (data.rows.length>0) { if (endpoint.requiredfields.includes("name")) { @@ -408,7 +408,7 @@ function CreateDynamicEndpoints() { }) app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then(async(data)=>{ if (data.rows.length>0) { var allExist=true @@ -430,7 +430,7 @@ function CreateDynamicEndpoints() { await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]) + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -447,7 +447,7 @@ function CreateDynamicEndpoints() { db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return "$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field])) + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -455,7 +455,7 @@ function CreateDynamicEndpoints() { res.status(500).send(err.message) }) }app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then(async(data)=>{ if (data.rows.length>0) { var allExist=true @@ -477,7 +477,7 @@ function CreateDynamicEndpoints() { await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return field+"=$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)} - }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]) + }}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -494,7 +494,7 @@ function CreateDynamicEndpoints() { db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{ if (!field.includes("_id")) {return "$"+(i+1)}else{ if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)} - }}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field])) + }}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -515,14 +515,14 @@ function CreateDynamicEndpoints() { app.patch(PREFIX+"/"+endpoint.endpoint,(req,res)=>{ if (req.body.id) { - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields] //console.log(combinedfields) var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) - return db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id]) + return db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id]) } else { var msg="Could not authenticate!";res.status(500).send(msg);throw msg } @@ -540,7 +540,7 @@ function CreateDynamicEndpoints() { app.delete(PREFIX+"/"+endpoint.endpoint,(req,res)=>{ if (req.body.id) { - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { return db.query('delete from '+endpoint.endpoint+' where id=$1 returning *',[req.body.id]) @@ -560,7 +560,7 @@ function CreateDynamicEndpoints() { }) app.get(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{ - db.query('select * from password where password=$1',[req.query.pass]) + db4.query('select * from password where password=$1',[req.query.pass]) .then((data)=>{ if (data.rows.length>0) { if (endpoint.requiredfields.includes("name")) { @@ -587,7 +587,7 @@ function CreateDynamicEndpoints() { }) app.post(PREFIX+"/test/"+endpoint.endpoint,async(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then(async(data)=>{ if (data.rows.length>0) { var allExist=true @@ -606,7 +606,7 @@ function CreateDynamicEndpoints() { var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) var requiresInsert=true if (endpoint.requiredfields.includes("name")) { - await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]]) + await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]]) .then((data)=>{ if (data.rows.length===0) { requiresInsert=true @@ -620,7 +620,7 @@ function CreateDynamicEndpoints() { }) } if (requiresInsert) { - db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field])) + db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field])) .then((data)=>{ res.status(200).json(data.rows) }) @@ -636,14 +636,14 @@ function CreateDynamicEndpoints() { app.patch(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{ if (req.body.id) { - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields] //console.log(combinedfields) var all_filled_fields=combinedfields.filter((field)=>(field in req.body)) - return db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id]) + return db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id]) } else { var msg="Could not authenticate!";res.status(500).send(msg);throw msg } @@ -661,7 +661,7 @@ function CreateDynamicEndpoints() { app.delete(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{ if (req.body.id) { - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { return db2.query('delete from '+endpoint.endpoint+' where id=$1 returning *',[req.body.id]) @@ -773,7 +773,7 @@ app.post(PREFIX+"/validUser",(req,res)=>{ }) app.post(PREFIX+"/saveskilltree",(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { return db.query('select * from skill_tree_data where class_id=$1 limit 1',[req.body.class_id]) @@ -799,7 +799,7 @@ app.post(PREFIX+"/saveskilltree",(req,res)=>{ }) app.post(PREFIX+"/test/saveskilltree",(req,res)=>{ - db.query('select * from password where password=$1',[req.body.pass]) + db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { return db2.query('select * from skill_tree_data where class_id=$1 limit 1',[req.body.class_id]) @@ -829,4 +829,4 @@ ENDPOINTDATA.forEach((endpoint)=>{ console.log(endpoint.endpoint+":\n\t"+endpoint.requiredfields.join('\t')+(endpoint.optionalfields.length>0?"\t":"")+endpoint.optionalfields.join("\t")) }) -CreateDynamicEndpoints() +CreateDynamicEndpoints() \ No newline at end of file From 7a8aed15dab2e74a91688d31c15512fbf760c999 Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Tue, 24 Aug 2021 04:24:23 +0000 Subject: [PATCH 04/14] add site data to seed. --- ngsplanner_seed.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 593d865..c5991f4 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -1,3 +1,4 @@ +delete from site_data; delete from skill_tree_data; delete from class_skill_data; delete from class_skill; From 692278b3e59bd13b435729f6d07cd66a92f7a65b Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Tue, 24 Aug 2021 04:29:29 +0000 Subject: [PATCH 05/14] Add in site data to prevent errors --- ngsplanner_seed.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index c5991f4..212378a 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -280,4 +280,6 @@ insert into class_skill_data(name,class_skill_id,dependency,level,effect,duratio insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,halflineheight) values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10,60); -insert into site_data(name,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.'); \ No newline at end of file +insert into site_data(name,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.'); +insert into site_data(name,data) values('h1','To please the soul'); +insert into site_data(name,data) values('h2',''); \ No newline at end of file From 61ea568fdadf30867ded0578a882cdd8f6f1be97 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 24 Aug 2021 10:15:24 -0500 Subject: [PATCH 06/14] Backend saving implemented --- server.js | 149 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 117 insertions(+), 32 deletions(-) diff --git a/server.js b/server.js index 0c60c42..b7ca165 100644 --- a/server.js +++ b/server.js @@ -740,17 +740,19 @@ app.get(PREFIX+'/data',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - if (endpoint.requiredfields.includes("name")) { - await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) - }) - } else { - await db.query('select * from '+endpoint.endpoint+" order by id desc") - .then((data)=>{ - finalresult[endpoint.endpoint]=data.rows - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + if (endpoint.requiredfields.includes("name")) { + await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) + }) + } else { + await db.query('select * from '+endpoint.endpoint+" order by id desc") + .then((data)=>{ + finalresult[endpoint.endpoint]=data.rows + }) + } } } res.status(200).json(finalresult) @@ -760,17 +762,19 @@ app.get(PREFIX+'/test/data',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - if (endpoint.requiredfields.includes("name")) { - await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) - }) - } else { - await db2.query('select * from '+endpoint.endpoint+" order by id desc") - .then((data)=>{ - finalresult[endpoint.endpoint]=data.rows - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + if (endpoint.requiredfields.includes("name")) { + await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) + }) + } else { + await db2.query('select * from '+endpoint.endpoint+" order by id desc") + .then((data)=>{ + finalresult[endpoint.endpoint]=data.rows + }) + } } } res.status(200).json(finalresult) @@ -780,11 +784,13 @@ app.get(PREFIX+'/dataid',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - await db.query('select * from '+endpoint.endpoint+' order by id asc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + await db.query('select * from '+endpoint.endpoint+' order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) + }) + } } res.status(200).json(finalresult) }) @@ -793,11 +799,13 @@ app.get(PREFIX+'/test/dataid',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - await db2.query('select * from '+endpoint.endpoint+' order by id asc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + await db2.query('select * from '+endpoint.endpoint+' order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) + }) + } } res.status(200).json(finalresult) }) @@ -869,6 +877,83 @@ app.post(PREFIX+"/test/saveskilltree",(req,res)=>{ }) }) +app.post(PREFIX+"/submitBuild",(req,res)=>{ + if (req.body.id) { + db.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id]) + .then((data)=>{ + console.log(data.rows) + if (data.rows.length>0&&data.rows[0].username===req.body.username) { + return db.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id]) + .then((data)=>{ + res.status(200).send(data.rows[0]) + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } else { + return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + res.status(200).send(data.rows[0]) + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } else { + return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + res.status(200).send(data.rows[0]) + }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } +}) + +app.post(PREFIX+"/test/submitBuild",(req,res)=>{ + if (req.body.id) { + db2.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id]) + .then((data)=>{ + if (data.rows[0].username===req.body.username) { + return db2.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data]) + .then((data)=>{ + res.status(200).send(data.rows[0]) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + } else { + return db2.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + res.status(200).send(data.rows[0]) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + } + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + } else { + return db2.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + res.status(200).send(data.rows[0]) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) + } +}) + //Generates our table schema: ENDPOINTDATA.forEach((endpoint)=>{ console.log(endpoint.endpoint+":\n\t"+endpoint.requiredfields.join('\t')+(endpoint.optionalfields.length>0?"\t":"")+endpoint.optionalfields.join("\t")) From 67ee65f803f0f670a36d9bfc4a9736da8c5f104e Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Wed, 25 Aug 2021 00:49:21 +0000 Subject: [PATCH 07/14] Update endpoints to make them more modular and submit to both sides at the same time. --- server.js | 76 +++++++++++---------------- server_test.js | 140 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 137 insertions(+), 79 deletions(-) diff --git a/server.js b/server.js index b7ca165..5414628 100644 --- a/server.js +++ b/server.js @@ -877,7 +877,7 @@ app.post(PREFIX+"/test/saveskilltree",(req,res)=>{ }) }) -app.post(PREFIX+"/submitBuild",(req,res)=>{ +function submitBuild(req,res,db,send) { if (req.body.id) { db.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id]) .then((data)=>{ @@ -885,73 +885,61 @@ app.post(PREFIX+"/submitBuild",(req,res)=>{ if (data.rows.length>0&&data.rows[0].username===req.body.username) { return db.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id]) .then((data)=>{ - res.status(200).send(data.rows[0]) + if (send) { + res.status(200).send(data.rows[0]) + } }) .catch((err)=>{ console.log(err.message) - res.status(500).send(err.message) + if (send) { + res.status(500).send(err.message) + } }) } else { return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) .then((data)=>{ - res.status(200).send(data.rows[0]) + if (send) { + res.status(200).send(data.rows[0]) + } }) .catch((err)=>{ console.log(err.message) - res.status(500).send(err.message) + if (send) { + res.status(500).send(err.message) + } }) } }) .catch((err)=>{ console.log(err.message) - res.status(500).send(err.message) + if (send) { + res.status(500).send(err.message) + } }) } else { - return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) - .then((data)=>{ + db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + if (send) { res.status(200).send(data.rows[0]) - }) - .catch((err)=>{ + } + }) + .catch((err)=>{ console.log(err.message) + if (send) { res.status(500).send(err.message) - }) + } + }) } +} + +app.post(PREFIX+"/submitBuild",(req,res)=>{ + submitBuild(req,res,db,true) + submitBuild(req,res,db2,false) }) app.post(PREFIX+"/test/submitBuild",(req,res)=>{ - if (req.body.id) { - db2.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id]) - .then((data)=>{ - if (data.rows[0].username===req.body.username) { - return db2.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data]) - .then((data)=>{ - res.status(200).send(data.rows[0]) - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) - } else { - return db2.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) - .then((data)=>{ - res.status(200).send(data.rows[0]) - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) - } - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) - } else { - return db2.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) - .then((data)=>{ - res.status(200).send(data.rows[0]) - }) - .catch((err)=>{ - res.status(500).send(err.message) - }) - } + submitBuild(req,res,db,true) + submitBuild(req,res,db2,false) }) //Generates our table schema: diff --git a/server_test.js b/server_test.js index 1117d03..1916f55 100644 --- a/server_test.js +++ b/server_test.js @@ -26,9 +26,6 @@ let allowCrossDomain = function(req, res, next) { app.use(allowCrossDomain); app.listen(PORT, () => console.log(`Listening on ${ PORT }`)); - var authenticated = true; - - const PREFIX="" const ENDPOINTDATA=[ @@ -695,17 +692,19 @@ app.get(PREFIX+'/data',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - if (endpoint.requiredfields.includes("name")) { - await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) - }) - } else { - await db.query('select * from '+endpoint.endpoint+" order by id desc") - .then((data)=>{ - finalresult[endpoint.endpoint]=data.rows - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + if (endpoint.requiredfields.includes("name")) { + await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) + }) + } else { + await db.query('select * from '+endpoint.endpoint+" order by id desc") + .then((data)=>{ + finalresult[endpoint.endpoint]=data.rows + }) + } } } res.status(200).json(finalresult) @@ -715,17 +714,19 @@ app.get(PREFIX+'/test/data',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - if (endpoint.requiredfields.includes("name")) { - await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) - }) - } else { - await db2.query('select * from '+endpoint.endpoint+" order by id desc") - .then((data)=>{ - finalresult[endpoint.endpoint]=data.rows - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + if (endpoint.requiredfields.includes("name")) { + await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val}) + }) + } else { + await db2.query('select * from '+endpoint.endpoint+" order by id desc") + .then((data)=>{ + finalresult[endpoint.endpoint]=data.rows + }) + } } } res.status(200).json(finalresult) @@ -735,11 +736,13 @@ app.get(PREFIX+'/dataid',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - await db.query('select * from '+endpoint.endpoint+' order by id asc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + await db.query('select * from '+endpoint.endpoint+' order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) + }) + } } res.status(200).json(finalresult) }) @@ -748,11 +751,13 @@ app.get(PREFIX+'/test/dataid',async(req,res)=>{ var finalresult = {} var promises = [] for (var endpoint of ENDPOINTDATA) { - await db2.query('select * from '+endpoint.endpoint+' order by id asc') - .then((data)=>{ - finalresult[endpoint.endpoint]={} - data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) - }) + if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") { + await db2.query('select * from '+endpoint.endpoint+' order by id asc') + .then((data)=>{ + finalresult[endpoint.endpoint]={} + data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val}) + }) + } } res.status(200).json(finalresult) }) @@ -824,6 +829,71 @@ app.post(PREFIX+"/test/saveskilltree",(req,res)=>{ }) }) +function submitBuild(req,res,db,send) { + if (req.body.id) { + db.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id]) + .then((data)=>{ + console.log(data.rows) + if (data.rows.length>0&&data.rows[0].username===req.body.username) { + return db.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id]) + .then((data)=>{ + if (send) { + res.status(200).send(data.rows[0]) + } + }) + .catch((err)=>{ + console.log(err.message) + if (send) { + res.status(500).send(err.message) + } + }) + } else { + return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + if (send) { + res.status(200).send(data.rows[0]) + } + }) + .catch((err)=>{ + console.log(err.message) + if (send) { + res.status(500).send(err.message) + } + }) + } + }) + .catch((err)=>{ + console.log(err.message) + if (send) { + res.status(500).send(err.message) + } + }) + } else { + db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) + .then((data)=>{ + if (send) { + res.status(200).send(data.rows[0]) + } + }) + .catch((err)=>{ + console.log(err.message) + if (send) { + res.status(500).send(err.message) + } + }) + } +} + +app.post(PREFIX+"/submitBuild",(req,res)=>{ + submitBuild(req,res,db,true) + submitBuild(req,res,db2,false) +}) + +app.post(PREFIX+"/test/submitBuild",(req,res)=>{ + submitBuild(req,res,db,true) + submitBuild(req,res,db2,false) +}) + //Generates our table schema: ENDPOINTDATA.forEach((endpoint)=>{ console.log(endpoint.endpoint+":\n\t"+endpoint.requiredfields.join('\t')+(endpoint.optionalfields.length>0?"\t":"")+endpoint.optionalfields.join("\t")) From 9ec51ea3d4361d67f1fca95d44a95c5fdd78100a Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 25 Aug 2021 06:00:39 -0500 Subject: [PATCH 08/14] Add password verification --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 5414628..4800640 100644 --- a/server.js +++ b/server.js @@ -882,7 +882,7 @@ function submitBuild(req,res,db,send) { db.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id]) .then((data)=>{ console.log(data.rows) - if (data.rows.length>0&&data.rows[0].username===req.body.username) { + if (data.rows.length>0&&data.rows[0].username===req.body.username&&data.rows[0].password_hash===sh.SecretHash(req.body.pass)) { return db.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id]) .then((data)=>{ if (send) { From 8c396bdec27f518857a943c65f47b40fe04bc5dd Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 25 Aug 2021 06:01:52 -0500 Subject: [PATCH 09/14] Add db verification --- server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 4800640..d7ce597 100644 --- a/server.js +++ b/server.js @@ -934,12 +934,16 @@ function submitBuild(req,res,db,send) { app.post(PREFIX+"/submitBuild",(req,res)=>{ submitBuild(req,res,db,true) - submitBuild(req,res,db2,false) + if (db2) { + submitBuild(req,res,db2,false) + } }) app.post(PREFIX+"/test/submitBuild",(req,res)=>{ submitBuild(req,res,db,true) - submitBuild(req,res,db2,false) + if (db2) { + submitBuild(req,res,db2,false) + } }) //Generates our table schema: From 0b07386a2a40b14a4002d537ca941adf81eaaff0 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 25 Aug 2021 09:53:37 -0500 Subject: [PATCH 10/14] Add description and icon fields to food table --- ngsplanner_patch.sql | 4 +++- ngsplanner_schema.sql | 2 ++ ngsplanner_seed.sql | 13 +++++-------- server.js | 41 ++++++++++++++++++++++++++++++++--------- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/ngsplanner_patch.sql b/ngsplanner_patch.sql index 5316e3f..6597a94 100644 --- a/ngsplanner_patch.sql +++ b/ngsplanner_patch.sql @@ -26,4 +26,6 @@ alter table class_skill_data alter column pp_consumption set data type text; alter table class_skill_data alter column max_hp_decrease set data type text; alter table class_skill_data alter column natural_pp_recovery set data type text; alter table class_skill_data alter column pb_gauge_fortification set data type text; -alter table site_data rename column field to name; \ No newline at end of file +alter table site_data rename column field to name; +alter table food add column description text; +alter table food add column icon text; \ No newline at end of file diff --git a/ngsplanner_schema.sql b/ngsplanner_schema.sql index d41cfa5..b0aa110 100644 --- a/ngsplanner_schema.sql +++ b/ngsplanner_schema.sql @@ -14,6 +14,8 @@ CREATE TABLE "food_mult" ( CREATE TABLE "food" ( "id" SERIAL UNIQUE PRIMARY KEY, "name" text, + "description" text, + "icon" text, "potency" boolean, "pp" boolean, "dmg_res" boolean, diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 212378a..a908457 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -1,4 +1,3 @@ -delete from site_data; delete from skill_tree_data; delete from class_skill_data; delete from class_skill; @@ -30,10 +29,10 @@ insert into food_mult(amount,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,we insert into food_mult(amount,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery) values(1,1.05,10,1.05,1.05,1,1,1,1); -insert into food(name,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice) - values('Rich Aelio Meat',true,false,false,false,true,false,false,false,0,0); -insert into food(name,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice) - values('Light Aelio Meat',true,false,false,false,false,true,false,false,0,0); +insert into food(name,description,icon,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice) + values('Rich Aelio Meat','Meat','',true,false,false,false,true,false,false,false,0,0); +insert into food(name,description,icon,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice) + values('Light Aelio Meat','Meat','',true,false,false,false,false,true,false,false,0,0); insert into class(name,icon) values('Hunter','/icons/UINGSClassHu.png'); insert into class(name,icon) values('Fighter','/icons/UINGSClassFi.png'); @@ -280,6 +279,4 @@ insert into class_skill_data(name,class_skill_id,dependency,level,effect,duratio insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,halflineheight) values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10,60); -insert into site_data(name,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.'); -insert into site_data(name,data) values('h1','To please the soul'); -insert into site_data(name,data) values('h2',''); \ No newline at end of file +insert into site_data(name,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.'); \ No newline at end of file diff --git a/server.js b/server.js index d7ce597..43ce955 100644 --- a/server.js +++ b/server.js @@ -886,7 +886,10 @@ function submitBuild(req,res,db,send) { return db.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id]) .then((data)=>{ if (send) { - res.status(200).send(data.rows[0]) + res.status(200).json(data.rows[0]) + } + if (db2) { + db2.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id]) } }) .catch((err)=>{ @@ -899,7 +902,10 @@ function submitBuild(req,res,db,send) { return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) .then((data)=>{ if (send) { - res.status(200).send(data.rows[0]) + res.status(200).json(data.rows[0]) + } + if (db2) { + db2.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice,id) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10,$11) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0,data.rows[0].id]) } }) .catch((err)=>{ @@ -920,7 +926,10 @@ function submitBuild(req,res,db,send) { db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0]) .then((data)=>{ if (send) { - res.status(200).send(data.rows[0]) + res.status(200).json(data.rows[0]) + } + if (db2) { + db2.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice,id) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10,$11) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0,data.rows[0].id]) } }) .catch((err)=>{ @@ -934,16 +943,30 @@ function submitBuild(req,res,db,send) { app.post(PREFIX+"/submitBuild",(req,res)=>{ submitBuild(req,res,db,true) - if (db2) { - submitBuild(req,res,db2,false) - } }) app.post(PREFIX+"/test/submitBuild",(req,res)=>{ submitBuild(req,res,db,true) - if (db2) { - submitBuild(req,res,db2,false) - } +}) + +app.get(PREFIX+"/getBuild",(req,res)=>{ + db.query('select * from builds where id=$1 limit 1',[req.query.id]) + .then((data)=>{ + res.status(200).json(data.rows[0]) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) +}) + +app.get(PREFIX+"/test/getBuild",(req,res)=>{ + db2.query('select * from builds where id=$1 limit 1',[req.query.id]) + .then((data)=>{ + res.status(200).json(data.rows[0]) + }) + .catch((err)=>{ + res.status(500).send(err.message) + }) }) //Generates our table schema: From 44830cceeedf573b339cbdfda3741887f607cd5a Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Fri, 27 Aug 2021 01:03:01 +0000 Subject: [PATCH 11/14] implement db4 with db --- server_test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server_test.js b/server_test.js index 1916f55..ca96eff 100644 --- a/server_test.js +++ b/server_test.js @@ -25,6 +25,8 @@ let allowCrossDomain = function(req, res, next) { } app.use(allowCrossDomain); app.listen(PORT, () => console.log(`Listening on ${ PORT }`)); + + const db4=db; const PREFIX="" From 5d1a71aeb9fac43c51b272aaff0c5ce91b416bac Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Fri, 27 Aug 2021 01:55:00 +0000 Subject: [PATCH 12/14] Added 'element' table, remove icon from augment_type and added icon and element_id to augment. --- ngsplanner_patch.sql | 36 ++--------- ngsplanner_schema.sql | 10 ++- ngsplanner_seed.sql | 76 +++++++++++++---------- patch_old/2021-08-09-ngsplanner_patch.sql | 31 +++++++++ 4 files changed, 89 insertions(+), 64 deletions(-) create mode 100644 patch_old/2021-08-09-ngsplanner_patch.sql diff --git a/ngsplanner_patch.sql b/ngsplanner_patch.sql index 6597a94..42fc84d 100644 --- a/ngsplanner_patch.sql +++ b/ngsplanner_patch.sql @@ -1,31 +1,5 @@ -/*9 Aug Database Patch*/ -alter table potential add column description text; -alter table weapon_existence_data add column icon text; -alter table weapon_type add column shorthand text; -alter table weapon_existence_data add column special_name text; -alter table potential drop column description; -alter table potential_data add column description text; -alter table photon_art add column icon text; -alter table users add column recovery_hash text; -alter table armor rename column pb_gauge_build to slot; -alter table armor add column battle_power_value text; -CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"data" text,"skill_data" text,"line_color" text,"line_width" int,"gridsizex" int,"gridsizey" int,"gridpaddingx" int,"gridpaddingy" int); -ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); -alter table skill_tree_data add column halflineheight int; -CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text); -alter table class_skill_data alter column damage_taken set data type text; -alter table class_skill_data alter column pa_potency set data type text; -alter table class_skill_data alter column conditional_buff set data type text; -alter table class_skill_data alter column pp_recovery set data type text; -alter table class_skill_data alter column property set data type text; -alter table class_skill_data alter column all_damage_buff set data type text; -alter table class_skill_data alter column active_pp_recovery set data type text; -alter table class_skill_data alter column status_ailment_accum set data type text; -alter table class_skill_data alter column status_ailment_duration set data type text; -alter table class_skill_data alter column pp_consumption set data type text; -alter table class_skill_data alter column max_hp_decrease set data type text; -alter table class_skill_data alter column natural_pp_recovery set data type text; -alter table class_skill_data alter column pb_gauge_fortification set data type text; -alter table site_data rename column field to name; -alter table food add column description text; -alter table food add column icon text; \ No newline at end of file +/*27 Aug Database Patch*/ +CREATE TABLE "element" ("id" SERIAL UNIQUE PRIMARY KEY,"name" text); +alter table augment add column element_id int; +alter table augment add column icon text; +alter table augment_type drop column icon; \ No newline at end of file diff --git a/ngsplanner_schema.sql b/ngsplanner_schema.sql index b0aa110..4e5d07b 100644 --- a/ngsplanner_schema.sql +++ b/ngsplanner_schema.sql @@ -162,7 +162,8 @@ CREATE TABLE "augment" ( "battle_power_value" int, "pb_gauge_build" float, "popularity" int, - "editors_choice" int + "editors_choice" int, + "element_id" int ); CREATE TABLE "skill" ( @@ -328,6 +329,11 @@ CREATE TABLE "site_data" ( "data" text ); +CREATE TABLE "element" ( + "id" SERIAL UNIQUE PRIMARY KEY, + "name" text +); + ALTER TABLE "builds" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id"); ALTER TABLE "users" ADD FOREIGN KEY ("roles_id") REFERENCES "roles" ("id"); @@ -365,3 +371,5 @@ ALTER TABLE "builds" ADD FOREIGN KEY ("class1") REFERENCES "class" ("id"); ALTER TABLE "builds" ADD FOREIGN KEY ("class2") REFERENCES "class" ("id"); ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); + +ALTER TABLE "augment" ADD FOREIGN KEY ("element_id") REFERENCES "element" ("id"); diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index a908457..0f94738 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -8,6 +8,7 @@ delete from food_mult; delete from food; delete from armor; delete from augment; +delete from element; delete from augment_type; delete from skill_data; delete from skill; @@ -200,39 +201,50 @@ insert into skill_data(skill_id,name,level,variance,mel_dmg,rng_dmg,tec_dmg,crit insert into skill_data(skill_id,name,level,variance,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,popularity,editors_choice) values((select id from skill where name='Fixa Termina' limit 1),'Fixa Termina Lv.3',3,0,0,0,0,0,1.10,0,0,0,0,0,0); -insert into augment_type(name,icon) - values('Stamina',''); -insert into augment_type(name,icon) - values('Spirit',''); -insert into augment_type(name,icon) - values('Might',''); -insert into augment_type(name,icon) - values('Precision',''); +insert into element(name) + values('Fire'); +insert into element(name) + values('Ice'); +insert into element(name) + values('Lightning'); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Stamina' limit 1),1,0,5,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Stamina' limit 1),2,0,10,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Stamina' limit 1),3,0,15,0,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,5,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Spirit' limit 1),1,0,0,3,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,2,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Spirit' limit 1),2,0,0,4,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Spirit' limit 1),3,0,0,5,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,4,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Might' limit 1),1,0,0,0,1.01,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Might' limit 1),2,0,0,0,1.015,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Might' limit 1),3,0,0,0,1.02,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Precision' limit 1),1,0,0,0,0,1.01,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Precision' limit 1),2,0,0,0,0,1.015,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0); -insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) - values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0); +insert into augment_type(name) + values('Stamina'); +insert into augment_type(name) + values('Spirit'); +insert into augment_type(name) + values('Might'); +insert into augment_type(name) + values('Precision'); +insert into augment_type(name) + values('Ice Weakness'); + +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Stamina' limit 1),1,0,5,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Stamina' limit 1),2,0,10,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Stamina' limit 1),3,0,15,0,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,5,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Spirit' limit 1),1,0,0,3,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,2,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Spirit' limit 1),2,0,0,4,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Spirit' limit 1),3,0,0,5,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,4,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Might' limit 1),1,0,0,0,1.01,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Might' limit 1),2,0,0,0,1.015,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Might' limit 1),3,0,0,0,1.02,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Precision' limit 1),1,0,0,0,0,1.01,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Precision' limit 1),2,0,0,0,0,1.015,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,null,''); +insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) + values((select id from augment_type where name='Ice Weakness' limit 1),1,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='Ice' limit 1),''); insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,slot,icon,popularity,editors_choice) values('Primm Armor',1,1,8,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,'/icons/20M6Z7t.png',0,0); diff --git a/patch_old/2021-08-09-ngsplanner_patch.sql b/patch_old/2021-08-09-ngsplanner_patch.sql new file mode 100644 index 0000000..6597a94 --- /dev/null +++ b/patch_old/2021-08-09-ngsplanner_patch.sql @@ -0,0 +1,31 @@ +/*9 Aug Database Patch*/ +alter table potential add column description text; +alter table weapon_existence_data add column icon text; +alter table weapon_type add column shorthand text; +alter table weapon_existence_data add column special_name text; +alter table potential drop column description; +alter table potential_data add column description text; +alter table photon_art add column icon text; +alter table users add column recovery_hash text; +alter table armor rename column pb_gauge_build to slot; +alter table armor add column battle_power_value text; +CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"data" text,"skill_data" text,"line_color" text,"line_width" int,"gridsizex" int,"gridsizey" int,"gridpaddingx" int,"gridpaddingy" int); +ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); +alter table skill_tree_data add column halflineheight int; +CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text); +alter table class_skill_data alter column damage_taken set data type text; +alter table class_skill_data alter column pa_potency set data type text; +alter table class_skill_data alter column conditional_buff set data type text; +alter table class_skill_data alter column pp_recovery set data type text; +alter table class_skill_data alter column property set data type text; +alter table class_skill_data alter column all_damage_buff set data type text; +alter table class_skill_data alter column active_pp_recovery set data type text; +alter table class_skill_data alter column status_ailment_accum set data type text; +alter table class_skill_data alter column status_ailment_duration set data type text; +alter table class_skill_data alter column pp_consumption set data type text; +alter table class_skill_data alter column max_hp_decrease set data type text; +alter table class_skill_data alter column natural_pp_recovery set data type text; +alter table class_skill_data alter column pb_gauge_fortification set data type text; +alter table site_data rename column field to name; +alter table food add column description text; +alter table food add column icon text; \ No newline at end of file From 32b56ed047562bf950523ac9e8a56a43043e4f5a Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Fri, 27 Aug 2021 01:57:23 +0000 Subject: [PATCH 13/14] Updated endpoint_data. Added 'none' element. --- ngsplanner_seed.sql | 2 ++ server.js | 12 +++++++++--- server_test.js | 12 +++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 0f94738..0b9985c 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -201,6 +201,8 @@ insert into skill_data(skill_id,name,level,variance,mel_dmg,rng_dmg,tec_dmg,crit insert into skill_data(skill_id,name,level,variance,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,popularity,editors_choice) values((select id from skill where name='Fixa Termina' limit 1),'Fixa Termina Lv.3',3,0,0,0,0,0,1.10,0,0,0,0,0,0); +insert into element(name) + values('None'); insert into element(name) values('Fire'); insert into element(name) diff --git a/server.js b/server.js index 43ce955..8e49ff3 100644 --- a/server.js +++ b/server.js @@ -175,14 +175,14 @@ const ENDPOINTDATA=[ }, { endpoint:"augment", - requiredfields:["augment_type_id","name"], - optionalfields:["variance","hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","affix_success_rate","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","popularity","editors_choice"], + requiredfields:["augment_type_id","name","element_id"], + optionalfields:["variance","hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","affix_success_rate","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","popularity","editors_choice","icon"], excludedfields:[] //Fields to not output in GET. }, { endpoint:"augment_type", requiredfields:["name"], - optionalfields:["icon"], + optionalfields:[], excludedfields:[] //Fields to not output in GET. }, { @@ -232,6 +232,12 @@ const ENDPOINTDATA=[ requiredfields:["name","data"], optionalfields:[], excludedfields:[] //Fields to not output in GET. + }, + { + endpoint:"element", + requiredfields:["name"], + optionalfields:[], + excludedfields:[] //Fields to not output in GET. } ] diff --git a/server_test.js b/server_test.js index ca96eff..b3e789d 100644 --- a/server_test.js +++ b/server_test.js @@ -129,14 +129,14 @@ const ENDPOINTDATA=[ }, { endpoint:"augment", - requiredfields:["augment_type_id","name"], - optionalfields:["variance","hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","affix_success_rate","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","popularity","editors_choice"], + requiredfields:["augment_type_id","name","element_id"], + optionalfields:["variance","hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","affix_success_rate","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","popularity","editors_choice","icon"], excludedfields:[] //Fields to not output in GET. }, { endpoint:"augment_type", requiredfields:["name"], - optionalfields:["icon"], + optionalfields:[], excludedfields:[] //Fields to not output in GET. }, { @@ -186,6 +186,12 @@ const ENDPOINTDATA=[ requiredfields:["name","data"], optionalfields:[], excludedfields:[] //Fields to not output in GET. + }, + { + endpoint:"element", + requiredfields:["name"], + optionalfields:[], + excludedfields:[] //Fields to not output in GET. } ] From 72a4897257b940d483aa33a023471e6161ea1807 Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Fri, 27 Aug 2021 02:29:36 +0000 Subject: [PATCH 14/14] Add none to all seeded augments --- ngsplanner_seed.sql | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 0b9985c..3c79777 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -222,29 +222,29 @@ insert into augment_type(name) values('Ice Weakness'); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Stamina' limit 1),1,0,5,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,null,''); + values((select id from augment_type where name='Stamina' limit 1),1,0,5,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Stamina' limit 1),2,0,10,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,null,''); + values((select id from augment_type where name='Stamina' limit 1),2,0,10,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Stamina' limit 1),3,0,15,0,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,5,0,0,0,null,''); + values((select id from augment_type where name='Stamina' limit 1),3,0,15,0,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,5,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Spirit' limit 1),1,0,0,3,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,2,0,0,0,null,''); + values((select id from augment_type where name='Spirit' limit 1),1,0,0,3,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,2,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Spirit' limit 1),2,0,0,4,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,null,''); + values((select id from augment_type where name='Spirit' limit 1),2,0,0,4,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Spirit' limit 1),3,0,0,5,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,4,0,0,0,null,''); + values((select id from augment_type where name='Spirit' limit 1),3,0,0,5,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Might' limit 1),1,0,0,0,1.01,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,null,''); + values((select id from augment_type where name='Might' limit 1),1,0,0,0,1.01,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Might' limit 1),2,0,0,0,1.015,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,null,''); + values((select id from augment_type where name='Might' limit 1),2,0,0,0,1.015,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Might' limit 1),3,0,0,0,1.02,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,null,''); + values((select id from augment_type where name='Might' limit 1),3,0,0,0,1.02,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Precision' limit 1),1,0,0,0,0,1.01,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,null,''); + values((select id from augment_type where name='Precision' limit 1),1,0,0,0,0,1.01,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Precision' limit 1),2,0,0,0,0,1.015,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,null,''); + values((select id from augment_type where name='Precision' limit 1),2,0,0,0,0,1.015,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) - values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,null,''); + values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='None' limit 1),''); insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon) values((select id from augment_type where name='Ice Weakness' limit 1),1,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='Ice' limit 1),'');