From 0b07386a2a40b14a4002d537ca941adf81eaaff0 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 25 Aug 2021 09:53:37 -0500 Subject: [PATCH] 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: